
views
On Windows 8/10
Install the JDK from the Oracle website. You can find the download here: https://www.oracle.com/technetwork/java/javase/downloads/index.html Make sure to download the JDK.
Identify the installation location of the JDK. It is usually a sub-folder within this path: C:\Program Files\Java
Edit the System Environment Variables. On the window that appears, click the "Environment Variables..." button.
Create a new variable named JAVA_HOME, and set the installation location of the JDK as the value.
Edit the PATH variable. Add a semicolon at the end. Add the JDK installation location with "\bin" after the semicolon.
Make sure to click "Okay" on all of the Environment Variables to save the new settings.
Open up Command Prompt. Hold ⊞ Win+R to open the "Run..." dialog. Enter cmd and hit ↵ Enter.
Verify the Java compiler is recognized. Type javac -version and hit ↵ Enter. If you see the version of Java printed out, it worked! If you see that it's "not recognized", go back and check the previous steps for any errors.
Run a Java program. Copy the Hello World program from Oracle's website and save it to a file: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html In Command Prompt, navigate to where to saved the file. If you're not comfortable with command prompt, there are many tutorials to help. Check out How to Change Directories in Command Prompt. Run javac HelloWorld.java(assuming your file is named HelloWorld.java) to compile your Java source file into a class file. If you see an error, you likely have a bug in your program or haven't navigated to where your file is located. Run java HelloWorld to run your compiled Java program.
On a Mac
Install the JDK from the Oracle website. You can find the download here: https://www.oracle.com/technetwork/java/javase/downloads/index.html Make sure to download the JDK.
Open the Terminal.
Verify the Java compiler is recognized. Type javac -version and hit ↵ Enter. If you see the version of Java printed out, it worked! If you see that it's "not recognized", go back and check the previous steps for any errors.
Run a Java program. Copy the Hello World program from Oracle's website and save it to a file: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html Navigate to where you saved the program. If you're not familiar with how to navigate in Terminal, there are many tutorials to help. Run javac HelloWorld.java (assuming your file is named HelloWorld.java) to compile your Java source file into a class file. If you see an error, you likely have a bug in your program or haven't navigated to where your file is located. Run java HelloWorld to run your compiled Java program.
Comments
0 comment