Mein Foto
Name:
Standort: Germany

made 62

Freitag, Juni 19, 2020

Java - the Oracle Problem and OpenJDK

Situation

The commercialisation coming with the change of Oracles license politics has called issues. To update now with Oracle causes to pay for the next main version. The alternate solution coud be to use OpenJDK.

But some may want to have the possibility to switch between these two versions.

Prerequisites

To get the proof and to check the correctness of this solution the installed Java versions should be uninstalled. I'm aware that this isn't wanted by someone. But only under this circumstances my procedure will be clean and tidy. I did so but found some things remaining after uninstalling it and I want to show which one. Let's do the check:
java -version
'java' is not recognized as an internal or external command,
operable program or batch file.
So Java is not present any more. Let's look what environment variable PATH is telling us. There's a tool for manipulating and better displaying PATH variable, I will show.
mypath list java
___ dir's actually ___
d:\Program Files\Java\jdk1.8.0_191\bin
As we can see even after uninstalling Java this directory did remain in the PATH. But no such directory was found anymore.

To set up the situation in assumpting an original Oracle Java was installed, the last free version of the originally Oracle Java 8 has to be downloaded. For this action it is required to create a Oracle account with your email address and log in. You can find Oracle Java here:
https://www.oracle.com/java/
Scroll down and find:
Download Java now >> Java SE 8 >> JDK Download
Then scroll down to Windows x64 and download the exe file, in my case: 
jdk-8u251-windows-x64.exe
The digits in the name 251 are a sub number of this version and may or may not have changed next time you visit this page. Install this Java version. It asks you for the directories for the JDK installation and the JRE installation, choose on own wishes. The best would be the choosen directories do not include spaces or extra characters in name, minus and underline are okay. Also avoid language specific characters with accent and so on.

Now let's look what is the result of it.
mypath list java
___ dir's actually ___
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
d:\Program Files\Java\jdk1.8.0_191\bin
As we can see the old non existing directory is present and the new directory with javapath in the end is set.

Solution

Now there is still the issue with the installed Oracle Java. What are the characteristics of the Oracle Java Installation?
  1. It installs (in my case) a directory javapath under C:\Program Files (x86)\Common Files\Oracle\Java\javapath
    or C:\ProgramData\Oracle\Java\javapath
    Attention! This now is a dir-link (Junction) to a directory in the same location: C:\ProgramData\Oracle\Java\javapath_target_141687
  2. This dirctory is added to the system environment variable PATH
  3. The directory contains 3 files that are only links to the 3 java files:
    • java.exe
    • javaw.exe
    • javaws.exe

    ... these links point directly to the original installations point of Java.
    C:\Programm\Java\jdk1.8.0_251\bin
  4. The dir comes with rigths for admins. So one needs admin rights to rename the directory or delete/or move the files.

A solution could be to:
  • once copy the 3 files to another location for cases of restore
  • rename the directory with admin rights to javapath.BAK
  • in the same parent dir create a new directory javapath which has no limitation to admin rights
  • do via hand or search a tool for changing the PATH-variable (e.g. tool Perl mypath)
    change the PATH by your wishes between the installed JDK's including original Oracle JDK

Be aware, that some already started tools in moment of change of PATH will cause errors. So end and start the tools a new.

For the simple switch from Oracle Java which is by default installed (Java 1.8):
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
respective now the linked dir:
C:\ProgramData\Oracle\Java\javapath_target_141687
to a self installed Java 13 there were done the following steps:
  • get local admin rights 
  • open control panel (Systemsteuerung) >> extended system settings (Erweiterte Systemseinstellungen) >> environment variables (Umgebungsvariablen)
  • system variables (Systemsvariablen) >> Path
  • input (add separated by a semi colon ';') the original javapath-dir followed by the Java 13 install dir respective the subdir bin like: c:\dokumente\java\jdk-13.0.1\bin
  • create two batch files in a sub-dir which is accessible via Path-variable
  • save/backup the links in the javapath-dir
  • java13.bat deletes the javapath-dir from the Path-variable, add's the Java 13-dir to PATH, deletes the 3 java*.exe-files from the javapath-dir
  • java18.bat adds the javapath-dir to the Path-variable, deletes Java 13-dir from PATH, copies the 3 java*.exe-files from the backup-dir to javapath-dir

Labels: , , , ,

0 Kommentare:

Kommentar veröffentlichen

Abonnieren Kommentare zum Post [Atom]

<< Startseite