Skip to content
Advertisement

How to downgrade JDK?

Currently my Java version is 17. Neo4j requires me to install Java 11 or OpenJDK 11, or else it will give the error java.lang.IllegalAccessException: module java.base does not open java.nio to unnamed module @1817d444. I guess I need to downgrade to JDK 11.

Java Platform, Standard Edition 11 Reference Implementations is the only place I can get JDK 11. However it seems to be a binary, not a setup. Checking C:Program FilesJava I found a folder for jdk-17 and jre1.8.0, so I copy the folder jdk-11 I just download to there. Checking the path environment I see these two lines:

C:Program FilesCommon FilesOracleJavajavapath
C:Program Files (x86)Common FilesOracleJavajavapath

Checking the javapath for 64-bit I see that there are java.exe, javac.exe, javaw.exe, jshell.exe. Does that mean that I should replace those files with the ones from jdk-11?

Advertisement

Answer

  1. Create new custom variable that point to the preferred version

  2. Set %JAVA_HOME%/bin as first entry to Path Variable

  3. Profit!

    Check with java -version

Why not just remove the Oracle Java path entry and not worry about your JAVA_HOME placement in the Path?

You might suggest to simply remove the Oracle Java path that was prepended to your Windows PATH by the installer. Yes, I thought of that too, but the installer also copies the java.exe, javaw.exe, and javaws.exe files to C:WindowsSystem32 directory, which is also in the Windows PATH variable. So rather than chase down all the possible directories that the installer put Java, and to avoid deleting the System32 files that actually may be necessary to some process somewhere, I decided that simply prepending my preferred Java Home directory to the path was best option.

Source: How to set custom Java path after installing JDK 8 – Douglas C. Ayers

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement