How to add jvm parameters for a runnable jar?

心已入冬 提交于 2019-12-06 05:59:10

问题


For the runnable jar that i am creating. it requires xmx1024 as JVM argument. How can i do this ? Or is there any alternative ?


回答1:


You can provide a startup script for each and every platform the program is intended to run on. For example on Linux you can have program.sh

java -mx1024 -jar lib/artifact.jar arg1 arg2

Obviously you have to tell the user that the program is intended to be run from the startup script, because if they try to manually start the jar it will fail.

You can even check in your program if the VM has been started with the required arguments and fail soon if not. Refer to this answer.




回答2:


There are tools like Capsule that can bundle an executable jar with JVM args and even platform-specific startup scripts.



来源:https://stackoverflow.com/questions/13787353/how-to-add-jvm-parameters-for-a-runnable-jar

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