Unfortunately, existing answers are wrong in one crucial point.
-Xmx
must be passed to the Java runtime environment, not to the executed jar.
Wrong:
java -jar JavaApplication.jar -Xmx1024m
Correct:
java -Xmx1024m -jar JavaApplication.jar
More specifically, the java launcher needs to be used as follows:
java [options] -jar file.jar [arguments]
[options]
are passed to the Java runtime environment
[arguments]
are passed to the main function
The -Xmx
parameter belongs to the (nonstandard) JVM options, and--being an option--needs to be listed before -jar (or at least before file.jar). The JVM will not recognize an -Xmx
argument passed to the main function as proposed in other answers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…