Change the JDK version number for Android Studio under Mac

Source: Internet
Author: User

Change the JDK version number for Android Studio under Mac

@author ASCE1885

Recent projects have shifted from Eclipse+ant build mode to Android Studio+gradle build mode. The natural JDK version number has also been upgraded from JDK6 to JDK7, but later discovered that since we are an SDK project and will finally be available to third parties in the form of a jar package, we will encounter a problem, assuming we use JDK7 to compile the jar package, while the third-party compilation environment uses the old JDK6 , then the project will be compiled with:

version51.0

Therefore, we need to reduce our Android Studioproject compilation Environment from JDK7 to JDK6. The following is a record of changes.

Path to different version numbers of the MAC system JDK

By default, the default installation folder for different version numbers of the MAC system JDK differs somewhat, as seen in the installation folders for Jdk6,jdk7 and JDK8, respectively:

/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
Changes to Android Studio

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

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

Changes to environment variables

As a result of the above changes, when we compile on the Android Studio UI interface, we will use our modified JDK6 version number, but when we enter java-version in terminal to view the current JDK version number information. You will find the JDK7 version number before. The possible cause is that the JAVA_HOME environment variable was previously set in the system. So we have to change it here.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvyxnjzte4odu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "title=" >

Open terminal. Enter the Vim ~/.bash_profile. Open this file with the following contents, such as:

Can see. The environment variable is indeed the previous JDK7 version number. Point it to the installation path of the JDK6.

The profile is then loaded into effect again:

source ~/.bash_profile
Changes to Jenkins

Self-initiated compilation using Tomcat+jenkins,jenkins's changes is simpler, on the Jenkins home page click [System Management]-[system settings]. Find the following JDK setup options to change it:

After the changes have been made, restarting Tomcat will result in a failure to access the Jenkins page because the Jenkins version number we are using has a minimum of JRE7 support, such as the following:

In the environment variable that step we have reduced the JDK version number from JDK7 to JDK6, this can be resolved by changing the Tomcat Jre_home, open the Tomcat installation folder bin/ Catalina.sh (because I'm using a Mac system, switch to Catalina.bat for Windows systems). Search for Jre_home, create new if not present, and assign value to JDK7 folder on your computer:

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

Change the JDK version number for Android Studio under Mac

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.