What if I wanted to execute a jar file with -Xms256m -Xmx256m flags? How is this possible. I have an app that requires a lot of memory to be avaliable, how can I set it up to run outside the IDE? Can I config an executable jar file? Do I use a batch file? Can I set those flags some other way in my code?
java -Xms256m -Xmx256m -jar
[quote] Do I use a batch file?
[/quote]
yes
No. The only other options is an executable launcher as this needs to be set when the Vm is launched. The various installer generators generally can do this.
Thanks Jeff
Hum… im looking at this tutorial http://today.java.net/pub/a/today/2004/04/30/cmdline.html?page=2 but the C code makes very little sense to me. All I want to achieve is a batch file that will execute the following command: -Xms256m -Xmx256m WindowClass. Can anyone help me with this?
Just put the line I gave you above in a batchfile,.
yes
Can I set those flags some other way in my code?
No. The only other options is an executable launcher as this needs to be set when the Vm is launched. The various installer generators generally can do this.
[/quote]
You can do these as part of a standard java bundle if you use webstart (these are two of the very very small number of command-line-args that webstart allows you to specify) - technically speaking, it’s just a particular form of “executable launcher”, but it’s also the way you’re supposed to package java apps.
got it, thanks
If you really hate batch files and know your user (or you) can always start a JAR by double clicking it, you could use a mini JAR file to start your big JAR file with the needed memory parameters.
There’s been a small thread about the topic a long time ago, which I started and with the help of some good forum people it worked very well then.
you can set some vm args inside your code with System.setProperty(), for example, you can set the opengl pipeline on, if any component is visible yet, if you call
System.setProperty("sun.java2d.opengl", "True");
you can set some vm args inside your code with System.setProperty(), for example, you can set the opengl pipeline on, if any component is visible yet, if you call
System.setProperty("sun.java2d.opengl", "True");
That’s a good hint and keyword.
In the same way it’s possible to set most (all?) of the Swing switches when your main class does it before any visual component is being created.
For example my typical main class loads some prefs and then issues:
System.setProperty("swing.aatext", "true");
… and then creates the JFrame and so on.
you can set some vm args inside your code with System.setProperty(), for example, you can set the opengl pipeline on, if any component is visible yet, if you call
System.setProperty("sun.java2d.opengl", "True");
Actually to be correct youcan set NO VM arguments from inside the program.
You can set properties. if those properties are read by the APIs libs after the point in your program where you set them, they will have an effect.