How to set the -Xmx when start running a jar file?
jar, java
Solution
try `java -Xmx1024m` filename.
I found this on StackOverflow What does Java option -Xmx stand for? and use it when I start Netbeans for instance.
use it like this
java -Xmx1024m -jar JavaApplication.jar
info: `-Xmxn` Specify the maximum size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts.
Problem
As we know that we can set `-Xmx1024M` in `window->preferences->java->installed jres->edit->default vm arguments` in eclipse. But when I package this project into a runnable jar file, how can I set the `-Xmx1024M` when running the jar via `java -jar A.jar`? Thanks a lot!