Using: jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) Server VM 1.7.0_76-b13 +indy [linux-i386]
When I try to use memory image source, which is in java.awt.Image, I get an "uninitialized constant" error. If I explicitly do
import java.awt.Image.MemoryImageSource
Then I get "undefined method `MemoryImageSource' for Java::JavaAwt::Image:Class ". Does JRuby just not support this class for some reason? Or, is MemoryImageSource somehow not in 1.7?
Edit: I wrote a quick Java test:
import java.awt.image.MemoryImageSource;
class HelloWorldApp {
public static void main(String[] args) {
MemoryImageSource ms;
System.out.println("Hello World! I can find MemoryImageSource"); // Display the string.
}
}
And I get no problems finding MemoryImageSource, so it seems like the problem is JRuby.
java -version
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) Server VM (build 24.76-b04, mixed mode)
Edit:
Realized it's not clear that other Java aspects work fine in JRuby (I can create a JFrame and draw little squares on it with a JPanel, for example).
Edit:
Maybe the problem is with how I'm trying to import MemoryImageSource? When I write a Java class that uses MemoryImageSource, I can access it from JRuby just fine (just not MemoryImageSource directly). For now, it's a decent workaround because my java returns the Image I created from MemoryImageSource without Ruby complaining.
I am still curious how I went wrong, though.
you just did something completely different (watch for proper casing) :
java_import java.awt.Image.MemoryImageSource
first resolves
java.awt.Image
which in your case (unfortunately) exists and than tries to call the MemoryImageSource
method on the Java class
what you're after is java_import java.awt.image.MemoryImageSource
thus JRuby assumes java.awt.image
is a package and looks for a class under it