Java BufferedImage with Lejos NXT: Java Heap Space
I'm a little puzzled by how you are getting these results, but I am assuming you are getting an error when you run the equivalent of nxjc and nxjlink on a supported platform. i.e., you are probably invoking nxj -r ...

Furthermore, I am assuming you are basing these commands on a recent Java compiler from Oracle; version 7 or 8.

First of all, it is my understanding that java.awt.image.* is not even present. The example showed here should not even compile because the only AWT classes we have access to are java.awt.Point and java.awt.Rectangle. 

Furthermore, only some of the javax.microedition.lcdui API is implemented, so you should check the documentation to see if Image is supported in the manner you want. So, for example, ImageIO is not present.

So, the example programs you show here are not going to even compile (never mind link) with the as-shipped latest version of leJOS NXJ.

At any rate, the size of the heap for leJOS is basically all of the RAM on the brick, but it is shared with the stack and static RW memory. But I'm not convinced the message you are seeing is related to the leJOS VM runtime heap, but rather the heap of the thing that is trying to create the classes and link them into the "TinyVM" before sending them to the brick.

We don't know because you have not described exactly how you are getting this message, with what command(s), with the full output of the exception(s)!

So, if you want to solve this, we need:


The platform you are running leJOS on.
The output of %LEJOS_NXT_JAVA_HOME%\bin\javac -version (assuming Windows; you know what to do for OS X or Linux)
For that matter, what is %LEJOS_NXT_JAVA_HOME% or ${LEJOS_NXT_JAVA_HOME} set to?
The output from the command you are running. Try capturing what comes out of nxj -v -r Main
The version of leJOS NXJ you are running


Place this in the body of your question, please.