Java 11 (LTS) · Topic 6 of 6
Run a single file without compiling
Definition​
Java 11 can run a .java file directly with java Hello.java. It compiles the file in memory and runs it, which is handy for small scripts and for learning.
Example code​
One file, one command
// file: Hello.java
class Hello {
public static void main(String[] args) {
System.out.println("Hello from a single source file");
}
}
// run it with one command, no javac step:
// java Hello.java
// Output:
// Hello from a single source file
Finished this page? Track your progress (saved only in your browser).