How to create an executable jar file with 1 GB heap

好久不见. 提交于 2019-12-20 04:37:31

问题


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.


回答1:


 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?




回答2:


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


来源:https://stackoverflow.com/questions/11879661/how-to-create-an-executable-jar-file-with-1-gb-heap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!