I created a class that gives a text file containing system performance as output. I want to run it as an executable Jar. but when I run the Jar I want to increase the heap to 1 GB.
If we run this program I can do this by running like this:
java -Xms1200m -Xmx1300m Sample
But how can I increase heap space using an executable Jar? When I click on the jar it must execute with a heap space of 1 GB.
java -Xms1200m -Xmx1300m -jar FILENAME.jar
Define this somewhere in the jar File or in the Manifest is not possible:
Can I set Java max heap size for running from a jar file?
As already mentioned: it unfortunately is not possible (without creating a wrapper, whether shortcut/script/executable ...).
If you're only running on Windows, I can recommend Launch4J to create an executable wrapper that can apply these settings on execution:
Wrapping it in a executable has other benefits:
- If a suitable version of Java is not found, it will prompt the user to download it
- Windows 7 Start Menu will treat it properly (highlighting it as a new application after installation)
- Windows Firewall will treat it properly