Recently I've been developing a small game engine in Java, which loads many png and jpg files and the default heap size that the JVM gives (64mb) seems to not be enough. I solved that matter by adding the following switches, as instructed by tutorials around the net:
Is there a way to include all these JVM options directly in the manifest file? In that way, I can skip the batch file and start the engine directly by double-clicking the jar file. I've been searching on the net the last couple of hours for that matter but I couldn't find a concrete answer.
Right now the manifest file includes only the following: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.2 Created-By: 1.5.0_03-b07 (Sun Microsystems Inc.) Main-Class: com.zefxis.SolarWind.GameMain X-COMMENT: Main-Class will be added automatically by build
And another question: The engine can be used in applet mode directly, with the same jar file. In that case, the browser directly initializes the GameApplet.class file through an <applet> or <object> tag. How can I include the above named JVM options when in applet mode without a manifest file? Can that be done through the html page and the above tags? Or does the applet read its manifest file? Is there a solution for this matter?
Right now, I managed to run the engine when in applet mode through Sun's own appletviewer by the below command-line argument: "C:\Program Files\Java\jdk1.5.0_03\bin\appletviewer" -J-Xss2048k -J-Xms64m -J-Xmx256m -J-Xmn50m -J-XX:+UseParallelGC -J-XX:+UseAdaptiveSizePolicy "EngineApplet (applet tag).html"
As you can see above I use Sun's latest developer tools, i.e. jdk 1.5.0_03 and netbeans 4.1 for writing the engine.
Thanx in advance for any opinions for this matter!
First off I would drop all but one of those switches unless you have metrics that show improvements as hard numbers. Keep -Xmx256m if that's how much you really need. As far as using the manifest to specify these options, those are non-standard options so you would not want that. Moreover, the applet runs in an existing JVM and does not get to dictate any JVM options.
Joined: Jan 26, 2005
Rick O'Shay thanks for the quick reply.
So, in applet mode there is no control of the JVM options, so I cannot use my engine with a bigger heap size in that mode, except of using appletviewer for test purposes? Seems rather odd that Sun didn't provide a solution for this matter.
I'll follow your advice about dropping most of the switches after doing some benchmarking of the engine. Thanks for also pointing that out.
Could you point out to me the non-standard options that I may include in the manifest file to avoid all the command-line switches? I understand that being non standard they may stop working in a newer Java version without proior notice, but at least I would be avoiding the command-line options for the time being.