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.