This page is about installing Java and making sure it is usable.
- 1 Install Java
- 2 Verify your Java installation
- 3 Setting up your programming environment for Java
- 4 Getting started with Java
Installing in GNU/Linux
Install Java jdk:
sudo apt-get install default-jdk
Or if you want to go for a specific Java version, you do any (or both) of the following:
sudo apt-get install openjdk-7-jdk
sudo apt-get install openjdk-8-jdk
sudo dnf install java-1.8.0-openjdk
Installing in Windows
Follow the instructions here.
- Installing and setting up Java JDK8 on Windows 10 (eng)
Installing in MacOS
On the download page click on Mac OS X link and follow the instructions.
Verify your Java installation
Here's some short things we would like you to go through to verify that your Java installation is correct.
Execute the program
java like this:
$ java -version openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-b13) OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode) $ echo $? 0
The printout from java is dependent on which version you have installed but if you see something similar to the above you have a working java installation. If you see a printout similar to
bash: java: command not found... you do not have a fully working installation. Make sure that the last command
echo $? prints
0 and not something else (i e
After installing the Java 8 JDK (n.b. the JDK, not the JRE), close any running cygwin terminals and start a new one. Check that you can run
java -version and that it replies by typing some Java version information.
Next, check that you can run
javac -version with a similar result. Don't panic if you get
javac - command not found. This is because the windows installer for the JDK is retarded and doesn't set the PATH variable in Windows System Environment Variables for the path to
If you can't run
javac, you need to set the PATH variable in Windows System Environment variables.
Typically, this can be achieved by opening the Control Panel and search for "environment" and choose "Edit System Environment Variables" (the one with a shield in front of it). In the System Properties dialog, click the button near the bottom labelled "Environment variables..." and in the next dialog, select "path" in the lower list of variables, "Edit" and paste in a new path to the directory where the
javac command is installed (typically something like "C:\Program Files\Java\jdk1.8.0_144\bin").
If you don't know how to find these settings or the installation folder for javac, consult your supervisor or teacher.
After adding the path to javac, restart the cygwin terminal (giving it a chance to read the new PATH) and issue
javac -version again and verify that the
javac command is found and run. If not, consult your teachers.
Verify that java works by typing the following in a terminal:
If you see a warning mentioning something like command not found your installation has NOT seucceeded. If you, on the other had, see a version number and some additional text printed in the terminal java is working.
Verify that javac works by typing the following in a terminal:
If you see a warning mentioning something like command not found your installation has NOT seucceeded. If you, on the other had, see a version number and some additional text printed in the terminal javac is working.
Setting up your programming environment for Java
Trouble shooting for Windows
Note that you must set the PATH variable in Windows, in order to run
javac (the Java compiler) in a terminal. Oracle has a page explaining how to do this.
Getting started with Java
Here's a video to get you started using Java: