Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if there is a problem installing multiple versions of JDK?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail what to do when installing multiple versions of JDK. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

One, background

1. Jdk1.8.0_91 was originally installed, because in order to run the server program locally, you need version 1.7, and you need to install 1.7.0

2, the original installation directory:

D:\ Program Files (x64)\ java\ jdk1.8.0_91

D:\ Program Files (x64)\ java\ jre1.8.0_91

3, the installation directory of the lower version:

D:\ Program Files (x64)\ java\ jdk1.7.0_79

D:\ Program Files (x64)\ java\ jre7

That is, all jdk and jre are installed in the same directory.

4, configure JAVA_HOME, CLASSPATH, and Path paths

JAVA_HOME=D:\ Program Files (x64)\ java\ jdk1.7.0_79

CLASSPATH=.;%JAVA_HOME%\ lib\ dt.jar;%JAVA_HOME%\ lib\ tools.jar

Path=C:\ ProgramData\ Oracle\ Java\ javapath;C:\ Program Files (x86)\ NVIDIA Corporation\ PhysX\ Common;%SystemRoot%\ system32;%SystemRoot%;%SystemRoot%\ System32\ Wbem;%SYSTEMROOT%\ System32\ WindowsPowerShell\ v1.0\; C:\ Program Files\ Lenovo\ Fingerprint Manager Pro\; D:\ Program Files\ VanDyke Software\ Clients\; D:\ Program Files\ Git\ cmd;D:\ Program Files (x64)\ apache-maven-3.3.9\ bin;D:\ Program Files (x64)\ nodejs\ D:\ Program Files\ Open × × ×\ bin;%JAVA_HOME%\ bin;%JAVA_HOME%\ jre\ bin

Second, problems.

Phenomenon description and problem troubleshooting:

1. After configuring the above environment variables, enter java-version in the command prompt window, and the version that appears is 1.8.0: 91. According to the method mentioned on the Internet, the value of the path variable is changed as follows, that is, the two% JAVA_HOME% variables are raised to the front, but after this, the problem of entering java-version remains the same:

Path=%JAVA_HOME%\ bin;%JAVA_HOME%\ jre\ bin;C:\ ProgramData\ Oracle\ Java\ javapath;C:\ Program Files (x86)\ NVIDIA Corporation\ PhysX\ Common;%SystemRoot%\ system32;%SystemRoot%;%SystemRoot%\ System32\ Wbem;%SYSTEMROOT%\ System32\ WindowsPowerShell\ v1.0\; C:\ Program Files\ Lenovo\ Fingerprint Manager Pro\; D:\ Program Files\ VanDyke Software\ Clients\; D:\ Program Files\ Git\ cmd D:\ Program Files (x64)\ apache-maven-3.3.9\ bin;D:\ Program Files (x64)\ nodejs\; D:\ Program Files\ Open × ×\ bin

2, and then what I tried to do was to put

D:\ Program Files (x64)\ java\ jdk1.8.0_91

D:\ Program Files (x64)\ java\ jre1.8.0_91

Transfer the two folders to the D:\ Program Files (x64)\ java1 directory, that is, transfer them out of the original path, and then execute the java-version prompt

"the system cannot find the file c:\ programdata\ oracle\ Java\ javapath\ java.exe". The problem lies in this directory.

After investigation, it is found that this directory is a hidden directory, which can be accessed through the command prompt window.

3. After investigation, it is found that there are three linked files in the original C:\ ProgramData\ Oracle\ Java\ javapath directory; point to the

D:\ Program Files (x64)\ java\ jre1.8.0_91\ bin\ java.exe

D:\ Program Files (x64)\ java\ jre1.8.0_91\ bin\ javaw.exe

D:\ Program Files (x64)\ java\ jre1.8.0_91\ bin\ javaws.exe

Then I delete three linked files

Note:

(1) the three linked files must be deleted before they can be created.

(2) when the following command is executed, the current working directory is:

C:\ ProgramData\ Oracle\ Java\ javapath

Create a linked file:

Execute the following commands in a command prompt window:

Mklink java.exe "D:\ Program Files (x64)\ java\ jre7\ bin\ java.exe"

Mklink java.exe "D:\ Program Files (x64)\ java\ jre7\ bin\ javaw.exe"

Mklink java.exe "D:\ Program Files (x64)\ java\ jre7\ bin\ javaws.exe"

4. After the creation, execute the java-version command prompt:

"Error: Registry key 'Software\ JavaSoft\ Java Runtime Environment'\ CurrentVersion'

Has value '1.8, but' 1.7'is required.

Error: could not find java.dll

Error: Could not find Java SE Runtime Environment. "

Obviously this is the registry problem, you just need to change the value of the CurrentVersion key:

Open Registry Editor: enter the regedit command at the start of "run" and enter

Let the next layer go down: finally select Java Runtime Environment

HKEY_LOCAL_MACHINE--- > SOFTWARE--- > JavaSoft--- > Java Runtime Environment

You can see here that there is a CurrentVersion in the name column of the window on the right. Double-click CurrentVersion to enter the editing window.

After the modification, click "OK".

At this point, go back to the command prompt, enter the java-version command, and everything is fine.

5, but then opened a command prompt window, and entered the java command with the following error:

Make sure that there is no problem with the linked files in the javapath directory, and that there is no problem with JAVA_HOME=D:\ Program Files (x64)\ java\ jdk1.7.0_79

Later, I thought that I had deleted C:\ ProgramData\ Oracle\ Java\ javapath; from the PATH variable, so I modified it as follows, and the problem was solved.

The final PATH is:

PATH=C:\ ProgramData\ Oracle\ Java\ javapath;%JAVA_HOME%\ bin;%JAVA_HOME%\ jre\ bin;C:\ Program Files (x86)\ NVIDIA Corporation\ PhysX\ Common;%SystemRoot%\ system32;%SystemRoot%;%SystemRoot%\ System32\ Wbem;%SYSTEMROOT%\ System32\ WindowsPowerShell\ v1.0\; C:\ Program Files\ Lenovo\ Fingerprint Manager Pro\; D:\ Program Files\ VanDyke Software\ Clients\; D:\ Program Files\ Git\ cmd;D:\ Program Files (x64)\ apache-maven-3.3.9\ bin D:\ Program Files (x64)\ nodejs\; D:\ Program Files\ Open × ×\ bin

The result of the final execution of the command java-version is as follows, normal.

This is the end of the article on "what to do if there is something wrong with installing multiple versions of JDK". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report