Java, Maven and Gradle 25 · Compile and run
Set the maximum heap size
Allow the JVM to use up to 2 GB of heap.
java -Xmx2g -jar app.jar
Official Java, Maven and Gradle 25 documentation
More compile and run commands
- Check the Java version
- Compile a source file
- Run a compiled class
- Run a single source file directly
- Run a jar
- Run with a classpath
All compile and run commands · Java, Maven and Gradle 25 cheatsheet