Installing Java Development Kit

Java is a free ecosystem and there are various JDK available. Downloading the official and most-used JDKs from Oracle is advised. The latest JDK  is available for download at https://www.oracle.com/technetwork/java/javase/downloads/index.html. Java SE is guaranteed to be backward compatible, thus it is recommended to always download the latest version. Java is available for all major operating systems, be it Linux, Windows, macOS, or Solaris.

On Windows, the installation of JDK is a simple process accompanied by an installation wizard. For macOS developers, there is an Apple Disk Image available to be mounted. On Linux, due to various distributions and package managers specifically, JDK is not available for each and every one of them. For distributions with the RPM package manager, there is a package prepared. For other distributions, there is a generic package made available by Oracle. The official JDK download site mentioned earlier in this chapter gives sufficient information on the downloading and installing of the JDK on a given operating system. 

There is one goal in common for users of every operating system: to have the JAVA_HOME environment variable set up, pointing to the folder where JDK was installed.

On the Windows operating system, go to Control Panel | System | Advanced SettingsEnvironment Variables. Ensure there is a variable named JAVA_HOME with a value properly set to JDK. On Windows, JDK is most commonly installed under C:Program FilesJavajdk{version}. On Linux, the status of the JAVA_HOME variable can be checked by opening a Terminal and issuing the echo $JAVA_HOME command.

If the value returned is empty, enter the export JAVA_HOME = /path/to/jdk command to set the value.

Installing JDK on macOS is pretty straightforward. First, you need to download the corresponding .dmg installation file from Oracle. The template of the file is as follows:

jdk-8uversion-macosx-x64.dmg

After downloading the .dmg file, double-click on it and a finder window will appear that contains the .pkg installer file. Click on the installer and follow the instructions to complete the installation. 

To check the JAVA_HOME environment variable is set up correctly on macOS, edit the .bash_profile file that resides on the home directory, which can be accessed via ~. It should contain an entry similar to the following:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_version.jdk/Contents/Home

Here, the version is the current version of JDK downloaded. Also, make sure that the JAVA_HOME environment variable is exported into the following PATH environment variable. PATH could contain more than one definition concatenated with semi-colons:

export PATH=$PATH:$JAVA_HOME/bin
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.151.44