Java.lang.OutOfMemoryError: Java heap space

Earlier today I was working on some packages for Backtrack 5 and I ran into this java error. I was attempting to run a new reporting tool called Magic Tree which is a java application, but every time I opened it, it would crash with the following error.

root@bt:~/Tools# java -jar MagicTree-1487.jar
JarClassLoader: Warning: Null manifest from input stream associated with: lib/MagicTree/
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(
        at com.simontuffs.onejar.JarClassLoader.copy(
        at com.simontuffs.onejar.JarClassLoader.loadBytes(
        at com.simontuffs.onejar.JarClassLoader.loadByteCode(
        at com.simontuffs.onejar.JarClassLoader.load(
        at com.simontuffs.onejar.JarClassLoader.load(
        at com.simontuffs.onejar.Boot.main(

At first I was pretty sure that I was missing the perl module XMLWriter but even after installing that I still had the error. Just in case you are installing this on a regular Ubuntu distro you will need:

root@bt:~/Tools# apt-get install libxml-writer-perl

So even after installing this I still had the same error so I dug a little deeper and it seems my Java install was running out of memory. This was kind of odd because the install of Backtrack I am using has 3 gigs of memory. I did some searching and figured out how to pass Java some new memory parameters on the command line.

java -Xms<initial heap size> -Xmx<maximum heap size>

Next I tried some new parameters:

root@bt:~/Tools# java -Xms128m -Xmx512m -jar MagicTree-1487.jar

Increasing the memory in this way allowed magic tree to open and function properly. It does seem I am having some Jave memory leak issues but for now this is a quick and dirty fix to the problem.

Building Java Programs: A Back to Basics Approach (2nd Edition) (Paperback)

List Price: $121.60
New From: $64.99 USD In Stock
Used from: $14.99 USD In Stock

Sams Teach Yourself Java in 24 Hours (5th Edition) (Paperback)

List Price: $39.99
New From: $5.95 USD In Stock
Used from: $0.01 USD In Stock