Switch between jjdk and jdk

1. Switch between jdk7 and jdk8

1.1, first install jdk7, configure the environment variable JAVA_HOME, and then install jdk8.

1.2. After installing jdk8, JAVA_HOME points to no modification, and executing java -version shows the previous jdk7 version information.

1.3 Next, we configure the environment variable JAVA_HOME and find that the path to configure jdk7, or the path to configure jdk8, or to scribble a path is still the same to display jdk8, java -version.

1.4 Finally, I found that when jdk8 was installed, C:\ProgramData\Oracle\Java\javapath; was added to the front of the system variable Path during the installation process, which was brought out when jdk8 was installed, and it was in Path At the top, so no matter whether you modify the registry or the Java console, it is useless. When the executed command searches for commands in the system variables, the first found is C:\ProgramData\Oracle\Java\javapath;, which is always jdk8. Then, we need to delete the C:\ProgramData\Oracle\Java\javapath; at the top of Path, so that we can modify JAVA_HOME to switch the required jdk environment.

1.5

After deleting, the following error will occur when java -version is executed

C:\Users\wcd>java -version
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

Then it may not work, because there are still three files java.exe, javaw.exe and javaws.exe under C:\Windows\System32, which also need to be deleted.

        analysis:

        It should be that when jdk8 is installed, it will overwrite the original jdk7 registry, and for the convenience of everyone, the environment variables are directly added, and there is no need to configure the environment variables of JAVA_HOME, but many people don't know it, so I will record it here.

Delete the box in the red box and execute java -version again.

1.6 This can be switched

table of Contents

1. Switch between jdk7 and jdk8


Guess you like

Origin blog.csdn.net/weixin_46729085/article/details/108379594