views:

632

answers:

3

Hey,

I'm trying to use the BufferedImage class in AWT. I'm using J2ME on IBM's J9 virtual machine.

When I try and call the BufferedImge.getRastor() method I get the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: java/awt/image/BufferedImage.getRastor()Ljava/awt/image/WritableRaster;

Now, from what I know about the JVM that error is basically telling me that the BufferedImage class does not have a method called getRastor() which returns a WritableRaster object, however this method is documented in the API and it's from version 1.4.2 so should be compatable with J2ME.

I have no idea what is going on here, can you help?

Cheers,

Pete

A: 

I don't think this is your answer... but since you quoted your exception and I assume you cut and pasted it, I'll try to help.

Isn't the method:

getRaster

not

getRastor

?

(sorry if this is not what it is ailing you...)

jedierikb
Sorry, I copied the error message (badly!) from the PDA my code is running on. I've doubled checked and I do call .getRaster()
(so that's not what the problem is)
A: 

You won't be able to use anything from AWT in J2ME since its not supported.

That happens because J2ME doesn't have AWT. AWT is intended to be used in desktop applications (Java SE), with a different user model and functionalities.

You can take a look at J2ME docs here

J2ME uses a different approach regarding GUIs, you may use the high level abstraction API (FORMS) and the low level API (CANVAS).

Decio Lira
That's very confusing - I can successfully execute code that uses java.awt.Image and java.awt.Frame (and more!) so why is it that these are supported and BufferedImage is not?
Maybe because your IDE has JavaSE on the classpath. I'm not sure.:/What are you using? the sun's Wireless toolkit? Or some proprietary toolkit? Can you sucefully run this code on the actual device?
Decio Lira
A: 

The accepted answer is not correct (as of 2009-08-05). Exactly which API's you have available depends on the configuration and profile combination you deploy. However, you do need to refer to the J2ME documentation for exactly which 1.4 classes and members are supported.

Using CDC 1.0 with Personal Profile 1.1 you get a cut-down version of Java SE 1.4. Personal Profile 1.0 is a cut-down Java SE 1.3. Both have a fairly complete implementation of AWT (no Swing, though).

We actually use J9's CDC/PP on handheld/PDA devices quite successfully.

Software Monkey