Putting java commands into a .jar file

Hey guys. I’ve got a question about putting -Xmx2048MB directly into a .jar file so that it increases the heap size every time I open the jar. Do I just pass this into the args array in my main method? Can I call this using actual Java code within my program?

I’m using Eclipse to generate the .jar files. Thanks guys.

I don’t think executable jars have any mechanism for this at all. Use Java Web Start or write your own launcher. Even a shell script/batch file will work, but then you have to supply one for every platform you support.

not tried this but it might work if you use in code

System.setProperty(“Xmx2048”, “true”);

Me too don’t think executable jars can do that. Manifest file doesn’t support arguments such as yours. As swpalmer says, webstart or your launcher…

This won’t work, it’d be equivilent to -DXmx2048, rather than -Xmx2048. The -X options need to be specified before the VM is running.

Kev

I ended up making an executable Unix file to launch it, and a batch for Windows. Thanks for the help, guys.