Compile Java programs using javac
¶
This page describes how to compile Java code using javac
.
Procedure¶
1. Load a GCC module¶
Before compiling a java program, the java
module has to be loaded.
To load the java module, enter the command:
2. Create a Java source file¶
Create and write a Java source file called hello_world.java
:
In nano, write the Java program as such:
class hello_world
{
public static void main(String[] args)
{
System.out.println("hello, world");
}
}
3. Compile the source file¶
To compile, enter the command:
4. Run¶
to run, enter: