Installing Java 17
Installing Java 17
Downloading
Scroll down to Java SE Development Kit 17.0.2 downloads. Click on the appropriate platform
(Linux, Mac, or Windows).
For mac, use the x76 DMG installer. Click the link to download the file.
For windows, use the x86 MSI Installer. Click the link to download the file.
Installing on Mac OS
Double click on the DMG file (It is probably in Downloads but you can move it elsewhere
before installing if you wish.)
This will open the dmg and show a pkg file. Double click that Icon to start the install.
Click Continue.
Click Install
The install procedure will ask for a password (or for a ‘touch’ if you have a biometric
enabled macbook).
Touch the biometric sensor or click ‘Use Password’ and enter your user account password
on the macbook.
It will proceed with install and finally show the following:
The install script will place the JDK in the directory tree at /Library/java.
You will need to add the correct directory with java binaries to the front of your path
variable in the terminal. Note that in these examples, I use the free product XQuartz for my
terminal and Unix environment. However, you can do the same thing with the native Mac
Terminal.
To open a terminal window, go to launchpad, type ‘Terminal’ in the search bar and click the
Terminal Icon.
To look at the value of your PATH variable (this is where the OS searches for programs to
run), type:
You will modify this by placing the binary directory for the java jdk ahead of the other
directories in the path. Use:
export PATH=/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home/bin:$PATH
Note that adding the ‘:$PATH’ at the end is cricital or your terminal will not be useable!
Now you should be able to use Java. Connect to a directory where you have your Java
source files.
Verify that you are using the correct version by typing ‘java –version’. It should show 17.0.2.
Then you can build java programs with the javac command and executing them by running
the Java runtime environment using the java command.
Installing on Windows 10
After you download the msi file from the Java download site, it should be in your Downloads
folder. You can move it elsewhere if you wish or leave it there. Double click on that file to
run it and install Java.
You will be walked through a series of dialog boxes. Accept all the defaults by clicking the
Next button each time.
At this point, windows may display a dialog asking if you wish to modify system software.
Click the Yes button to allow the install to continue.
u
Click the Close button to dismiss the final dialog. Java is now installed and should be
available at your command prompt.
Run the command prompt (terminal) window by searching for CMD and selecting
‘Command Prompt’.
Using Java 17 on Windows 10
If it shows version 17.0.2 is installed ,you are ready to build and run programs. Change your
default folder to one containing your Java source code.
To build a program, type javac and the program name (see below). To execute the generate
class file, just type java followed by the class name (no .class extension).