Running a Java program
On Mac OS X
Created with Java Version 8 (Update 73)


Save the program - Hello.class

Open the terminal app in Applications/Utilities

Go to the folder where you saved it using the cd (Change Directory) command
e.g. "cd Downloads"
type "/usr/bin/java Hello"

In Windows 10 :
Save the program - Hello.class In Edge, IE or Firefox click on it and select save or keep. In Chrome right click and select "Save link as" Press the windows logo key +R to get the run or search box or select the "Ask me anything" box on the bottom left. Type "cmd.exe" (or just "cmd"). Go to the command processor/terminal/prompt/shell window you just opened. Go to the folder you specified for downloads (Downloads is the default). e.g. "cd C:\Users\User_name\Downloads" (change directory [cd] to Downloads) Type "java Hello" (Do not type "Hello.class")
I had a lot of trouble compiling and running Java. Some things I tried. I don't know which were required. Download the latest JDK. Java SE Development Kit 8 - Downloads I put "JAVA_HOME=/Library/Java" in my .profile I and a lot of other people got the following when running: "Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit" See How to fix "Could not create the Java Virtual Machine" Errorkombitz | kombitz My problem was I was typing "java Hello.class" instead of "java Hello"

Links:
Verify Java Version
Java Downloads for All Operating Systems | Java.com
Java SE - Downloads | Oracle Technology Network | Oracle.com

last updated 23 Mar 2016