Compiling and Running
Compiling
Once Java and Java JDK have been installed Java programs can be compiled using javac
man javac
NAME
javac - Reads Java class and interface definitions and compiles them
into bytecode and class files.
SYNOPSIS
javac [ options ] [ sourcefiles ] [ classes] [ @argfiles ]
Examples
Explicitly list java source files to compile
javac Main.java
Compile all .java files in the current directory
javac *.java
This will generate .class files in the current directory.
These can be executed using the java command, if they contain a
public static void main(String[] args)
method.
Running
The java command is used to run .class files that have a main method.
man java
NAME
java - Launches a Java application.
SYNOPSIS
java [options] classname [args]
Examples
java Main
Which will output
Hello, World!