[Go] mac Modify the JDK version used by Android Studio

Source: Internet
Author: User

Original link: http://www.jianshu.com/p/d8d1d72d0248#

The recent project moved from the Eclipse+ant build mode to the Android Studio+gradle build mode, and the natural JDK version number was upgraded from JDK6 to JDK7, but later discovered that since we are an SDK project, it will eventually be available to third parties in the form of a jar package. , there is a problem, if we use JDK7 to compile the jar package, and the third-party compiler environment uses the old JDK6, then the project will be compiled:

51.0

So we need to drop our Android Studio Engineering compilation Environment from JDK7 to JDK6, and here's the change record.

Mac system JDK Different versions of the path

By default, the default installation directory for different versions of the MAC system JDK differs somewhat, and the installation directories for JDK6,JDK7 and JDK8 are as follows:

/system/library/java/javavirtualmachines/1.6. 0. jdk/contents/Home/library/java/javavirtualmachines/jdk1. 7.0. jdk/contents/Home/library/java/javavirtualmachines/jdk1. 8.0. jdk/contents/home

Modifications to Android Studio

Click File-other settings-default Project Structure for Android Studio:

Opens the Project Structure dialog box, where you can modify the path of the Android SDK and JDK:

Modification of environment variables

As a result of the above modification, we will use our modified version of JDK6 when compiling on the Android Studio UI interface, but when we enter java-version in terminal to view the current JDK version information, we will find the previous JDK7 version. The possible reason is that the JAVA_HOME environment variable has been set up in the system before, so we have to modify it here.

Open terminal, enter Vim ~/.bash_profile, open the file with the following:

As you can see, the environment variable is indeed the previous version of JDK7, which points to the JDK6 installation path. Then reload the profile to take effect:

source ~/.bash_profile
Modification of Jenkins

Automated compilation uses the Tomcat+jenkins,jenkins modification is relatively simple, on the Jenkins home page click [System Management]-[system Settings], find the following JDK settings options to modify:

After the modification is complete, restarting Tomcat will result in the failure of the Jenkins page to fail because the Jenkins version we are using has a minimum of JRE7 support and the official website is as follows:

In the context of the environment variable we have reduced the JDK version from JDK7 to JDK6, which can be resolved by modifying the Tomcat Jre_home parameters, open the Tomcat installation directory bin/ Catalina.sh (because I am using a Mac system, Windows system switch to Catalina.bat), search for jre_home parameters, if not present, new, and assigned to the JDK7 directory on the computer:

JRE_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

[Go] mac Modify the JDK version used by Android Studio

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.