Method for setting the default version of Java under Mac _java

Source: Internet
Author: User
Tags mixed

This article first gave you a way to switch the Java version, and then introduced how to achieve permanent effect, the following words do not say more, together to see the detailed steps.

The previous version of Java under Mac was 1.7.

Java-version
java Version "1.7.0_71"
Java (tm) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot (tm) 64-bit Server VM (build 24.71-b01, Mixed mode)

After the 1.8 version is installed, the execution Java -version command still displays 1.7 version information. How do I switch to version 1.8? Just execute a few of the following commands.

Export java_home=/library/java/javavirtualmachines/jdk1.8.0_40.jdk/contents/home/
export path= $JAVA _home/bin : $PATH

After the command has finished, execute the java -version command.

Java-version
java Version "1.8.0_40"
Java (TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot ( TM) 64-bit Server VM (build 25.40-b25, Mixed mode)

If you want to take effect permanently, add the command to your profile.

echo ' Export java_home=/library/java/javavirtualmachines/jdk1.8.0_40.jdk/contents/home/' >> ~/.bash_profile
Source ~/.bash_profile

Summarize

The above is the Mac set the Java default version of the full content of the method, we have learned it? Hope that the content of this article for everyone's study or work can bring some help, if you have questions you can leave a message.

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.