[Go] Implementing a coexistence solution for multiple Java JDK on Windows

Source: Internet
Author: User

Issue background

The JDK environment applied to the company's project was 1.6, and recently, when I was learning IntelliJ idea in the SDK multi-environment configuration, I wanted to install Jdk1.8 as a learning base. So the problem comes, the company project extension does not support jdk1.8, in order to meet the company's project development environment, but also to meet the needs of learning jdk1.8, of course, not every time the JDK installation and uninstallation, need to explore another new method.

Analyze problems

In order to M.F.B. s solve the current problem, my idea is to install both jdk1.6 and jdk1.8 in Windows, switching between them in the middle without having to repeat the installation and uninstallation multiple times, which is simple and convenient.

Solution Ideas
    1. First step: Before installation, the native JDK environment is jdk1.6, execute: java -version , display the current JDK version is 1.6

    1. Step Two: Install jdk1.8 and let two jdk coexist. 安装教程是:直接 下一步 and 下一步after the installation is complete, set the following settings for the JDK environment variables:

      JAVA8_HOME =jdk1.8的安装路径
      JAVA6_HOME =jdk1.6的安装路径
      JAVA_HOME = %JAVA6_HOME% (注意:如果你想切换jdk,就在此处设置即可)

After setting the environment variable as shown:

    1. Step three: Add %JAVA_HOME%\bin to the environment variable path, as shown in the following path:

After the environment variable is configured, the following issues occur after installation:
By java -version  Viewing the display, the JDK appears as: jdk1.8
分析: 
The current JDK version is 1.8, which is unscientific, because the environment variable is configured in the Java_home is the path of 1.6, the view version should be 1.6 of the right, now become 1.8,JDK environment variable has not been changed, through the query to find the problem:

在安装JDK1.8时(本机先安装jdk1.6再安装的jdk1.8),自动将java.exe、javaw.exe、javaws.exe三个可执行文件复制到了C:\Windows\System32目录,由于这个目录在WINDOWS环境变量中的优先级高于JAVA_HOME设置的环境变量优先级。  

解决方案:

删除C:\Windows\System32目录下的java.exe,删除即可。

注意: If there is one in path  C:\ProgramData\Oracle\Java\javapath;  , delete it. Otherwise, the argument is wrong.

    • Fourth step: When the above configuration is complete, open a new  cmd  window, view the JDK version display is normal, in the environment variable switch java_home value is: JAVA_HOME=%JAVA8_HOME%  , view the JDK version, successfully switch. :

Summarize

After being abused by the Community editor, I finally wrote the tutorial, (or blame myself, not familiar with the Community editor, will be more practice later). Bitter languish night finally out of the night, PS: is a cat point awake, although very low, or to thank him, 阿里嘎多!! 
This tutorial also has a lot of shortcomings, not considered the place, I hope that we work together to improve it, so that it is more perfect. Thank you! In this article I refer to the following links:

Https://coderwall.com/p/gbek2g/java-6-and-java-7-on-windows
Http://blog.sina.com.cn/s/blog_437ee9d00101isob.html

[Go] Implementing a coexistence solution for multiple Java JDK on Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.