README.md 651 B

Working with the Java Programming Language

To build and run a Java program, ie. HelloWorld.java from a CLI

Ex HelloWorld.java

import java.io.*;

public class HelloWorld {
  public static void main ( String[] args)
  {
    System.out.println("Hello, Java!\n");
  }
}

Compile the HelloWorld.java

/path/to/javac /path/to/HelloWorld.java

The above command should generate a Java class file in the same directory of the HelloWorld.java file.

To run the HelloWorld.class program

/path/to/java /path/to/HelloWorld

Omit the .class extension when running a Java program from a CLI