Can I set Java max heap size for running from a jar file?

后端 未结 8 1786
刺人心
刺人心 2020-11-28 10:16

I am launching a java jar file which often requires more than the default 64MB max heap size. A 256MB heap size is sufficient for this app though. Is there anyway to speci

8条回答
  •  爱一瞬间的悲伤
    2020-11-28 10:59

    Write a batch or shell script containing the following line. Put into the folder, where MyApp.jar is stored.

    java -Xmx256M -jar MyApp.jar
    

    After that always open this batch/script file in order to launch the JAR file. Although, This will not embed specification of virtual memory size into jar file itself. But, It can override the problem to write the same command often on command line.

提交回复
热议问题