Troubleshooting Java Runtime Environment Installation for Java 8

Verifying Installation Version Used by System Path

Verify the Java version located in your System Path by opening a command prompt (Windows) or terminal window (Mac and Linux), then enter the following command: java -version and press the ‘Enter’ key. You should expect to see output displaying either the installed version of Java Runtime Environment (JRE) or an error message indicating that the command is not recognized. The JRE version should begin with 1.8.0_ followed by the specific update version (i.e., java version "1.8.0_261").

If you followed the steps for JRE 1.8 installation, but the system does not recognize the command, or the version displayed is not the version installed; then the installed files are not included in your system's Path. There is a special PATH variable in Windows and Linux based environments that contains a list of directories, which the system will search when a command is entered to identify any executable files with the same name. 

You can display the contents of the PATH variable:

  • Windows: echo %PATH%: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_265\bin...(abbreviated)
  • Linux: /home/ubuntu/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin... (abbreviated)

Even if there are multiple matches for the command within the directores that are included in the Path variable, the first match will be used.

You can identify which binary will be used in Linux by using the `which` command, and you can identify where the binary is located in Windows by using the `where` command.

  • which java: 
    /usr/bin/java
  • where java:
    c:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
    C:\Program Files\Java\jdk1.8.0_265\bin\java.exe

Configuring Your System to Use a Specific JRE Installation

To configure your system to use a specific installation of JRE when you run a java binary such as: java, javaws,  javac; you must do one of the following:

  • add the location for those files to the system path
  • add an alias command that will execute the specific binary

Windows

In Windows, you can rename the java.exe, javaws.exe, and javac.exe files in the installation you want to use to java1.8.exe, javaws1.8.exe, and javac1.8.exe and copy the entire java installation directory to one of directories include din the path variable, or you can update the path variable.  Updating the path variable in Windows is outisde the scope of this document.

Linux

In Linux you can add a symbolic link to one of the directories in the Path variable, using an alias to refer to the java binary you want to use:

  • ln -s /<installation-directory>/bin/java /usr/bin/java1.8
  • ln -s /<installation-directory>/bin/javac.exe /usr/bin/javac1.8
  • ln -s /<installation-directory>/bin/javaws.exe /usr/bin/javaws1.8

If you require sudo priveleges to make symbolic links in this way, you can add an alias to your user's bashrc file.

  • Open ~/.bashrc in a text editor
  • Go to the end of the file
  • Add aliases like the links you tried to create in the pervious step:
    • alias java1.8= '/<installation-directory/bin/java'
    • alias javaws1.8= '/<installation-directory/bin/javaws'
    • alias javac1.8= '/<installation-directory/bin/javac'
  • Save the file and close
  • Reload the .bashrc file: `source ~/.bashrc`

You may now run: `java1.8 -version` and you should see the version for the version of java you installed.

With future installations/upgrades to Java you may either update sybmolic links, or update the location used by aliases added to your ~/.bashrc file.

You may now substitute the commands: java1.8 and javaws1.8 for the commands java and javaws, respectively in the Download Manager instructions.