Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Free switching of mac Apple Multi-version jdk

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Scene

The tools on hand sometimes rely on a lower version of jdk and sometimes require a higher version of jdk. How to switch back and forth freely between different versions of jdk?

Installation

The first choice is to download the dmg installation package from the official website, address: https://www.oracle.com/technetwork/java/javase/downloads/index.html

How to install dmg, skip here, do not know their own Baidu bar.

My installation directory:

/ Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk

/ Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk

Configure the environment

Method 1:

Vi .bash _ profile / / Editor

Source .bash _ profile / / effective new configuration

# set JDK 7

Export JAVA_7_HOME= `/ usr/libexec/java_home-v 1.7`

# set JDK 8

Export JAVA_8_HOME= `/ usr/libexec/java_home-v 1.8`

# default JDK 8

Export JAVA_HOME=$JAVA_8_HOME

# alias command to dynamically switch JDK version

Alias jdk7= "export JAVA_HOME=$JAVA_7_HOME"

Alias jdk8= "export JAVA_HOME=$JAVA_8_HOME"

Method 2:

# hard coding method, not recommended

Export JAVA_7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

Export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home

Export JAVA_HOME=$JAVA_8_HOME / / default JDK

Alias jdk7='export JAVA_HOME=$JAVA_7_HOME'

Alias jdk8='export JAVA_HOME=$JAVA_8_HOME'

View

View the current version

Java-version

View the installation path of the default jdk

/ usr/libexec/java_home

View the installation path for jdk 1.7

/ usr/libexec/java_home-v 1.7

In previous versions, without this command, you should use a fixed / Library/Java/Home directory, that is, write to death directly in the environment variable.

Today's featured recommendation

JMeter Interface Test-if Controller

JMeter database operation

Jmeter Interface Test-regular expression

JMeter returns garbled code in Chinese

Jmeter interface testing-parameterization

JMeter Interface testing-Basics

Test-impression

Add Wechat to the consulting work

scan a QR code

Welcome self-recommendation and recommendation, need Wechat to push resume!

Please poke the QR code below to learn more.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report