Java6 and Java8 coexist on windows

Source: Internet
Author: User

0x00 Requirements

Recently in an Android project, the first installation was JAVA8 for project development. However, in the latter part of the project need to use Drozer to detect the security of the project, to build Drozer test environment must use JAVA6, otherwise there will be problems to cite the official instructions

It is very important, Java 1.6 is installed and used. This is because Android bytecode are only compliant to
Version 1.6 and not higher versions. Making use of all version of Javac other than 1.6 would result in errors during
Compilation the similar to the following:

Trouble processing:
Bad class file Magic (Cafebabe) or version (0033.0000)
... while parsing classloadtest.class
... while processing Classloadtest.class
1 warning
No Classfiles specified
Error whilst building APK bundle.

0x01 workaround

1. First step: Download two different versions of Java, and then install them separately. (I installed the default installation path, of course you can also customize the installation path)

2. The second step: The following is to configure the environment variables, my computer-right-to-property, select Advanced system Settings-environment variables.

  

  

3. Select the path in the user's environment variable and delete the ' C:\ProgramData\Oracle\Java\javapath; ' environment variable, if you do not delete the problem will occur, the input java-version will always be installed in the first version of Java.

4. Configuring environment variables for JAVA6 and JAVA8

The new two system variables in the system variable are java6_home and Java8_home, each of which is selected for their respective installation paths when they are created.

  

5. Setting CLASSPATH Environment variables

Same as 4 create a system variable with a variable name of classpath, the value of the variable is:

Note that the previous "." Also to be copied in.

6. Complete the system's Java settings

Create a new environment variable named Java_home in the system variable with a value of Java6_home or Java8_home. Then select path in the system variable and add the following code after the value of the variable

  

configuration in Windows7:; %java_home%\bin;%java_home%configuration in \jre\bin Windows10:%java_home%\ bin%java_home%\jre\bin

7. Delete Java.exe, Javaw.exe, javaws.exe three files under C:\Windows\System32.

0x02 test

When the variable value of Java_home is java6_home:

When the variable value of Java_home is java8_home:

0X03 precautions
    1. Be sure to delete the ' C:\ProgramData\Oracle\Java\javapath; ' in the user variable;
    2. Be sure to delete the three EXE files with Java in System32
    3. After you modify the value of the Java_home variable, you need to determine the end, and then exit the current CMD command Window environment variable will not take effect

  

Java6 and Java8 coexist 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.