Skip to content

Instantly share code, notes, and snippets.

@williamhaley
Last active December 16, 2020 19:58
Show Gist options
  • Save williamhaley/35d9e7657c7fa7ff738236be78878f96 to your computer and use it in GitHub Desktop.
Save williamhaley/35d9e7657c7fa7ff738236be78878f96 to your computer and use it in GitHub Desktop.
NCP Java Demo (Hello World)

NCP Java Install Instructions

Install Java on your computer. Your computer must be a Windows, macOS, or Linux computer. Not a Chromebook. You may also need to reboot.

Open the terminal program on your computer. On macOS it is called "Terminal". On Windows it is called "Command Prompt". Run the java command. Then run the javac command. If you see a message like "command not found", then Java is not properly installed.

Click the Download Zip button in the upper right hand corner of this page. Once the download is complete copy all the Java files to your Desktop.

Hello World Example

Open your computer's terminal program and use the cd command to change directory to your Desktop.

Windows

cd \Users\%username%\OneDrive\Desktop

or

cd \Users\%username%\Desktop

macOS and Linux

cd $HOME/Desktop

Compile the program

javac HelloWorld.java

Run the program

java Main
class Main {
public static void main(String[] args) {
System.out.println("hello world");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment