icon.png位于myapp.jar
内DANIELs-MacBook-Air-2:jrubyScreenshot dani [master] $ jar -tf myapp.jar | tail
....
icon.png
我该如何加载它? 这将返回nil
f = java.lang.Object.new
image = java.awt.Toolkit::default_toolkit.get_image(f.java_class.resource("icon.png"))
解决方案是:
f = java.lang.Object.new
url = f.java_class.resource("/icon.png")
答案 0 :(得分:1)
也许是CLASSPATH
> jruby -J-classpath myapp.jar test.rb
include Java
f = java.lang.Object.new
url = f.java_class.resource("/icon.png")
image = java.awt.Toolkit::default_toolkit.get_image(url)
puts image