# ubuntu 18.04 多版本java的安裝與切換 ###### tags: `Ubuntu` 文章: https://ywnz.com/linuxjc/2948.html ## 安裝 openjdk-8-jdk ``` $ sudo apt install openjdk-8-jdk ``` 安裝的路徑在:/usr/lib/jvm 裡面 ``` $ cd /usr/lib/jvm/ ; ls -al ``` ## 切換版本 ``` $ which java ``` 可以看到在 /usr/bin/java ,他是一個連結指向/etc/alternatives/java, 在查看/etc/alternatives/java 也是一個連接指向/usr/lib/jvm/java版本位置 所以只要改變這個就可以切換java了 用這個指令去改變 ``` sudo update-alternatives --config java ``` 選擇好後java -version檢查是否已經改變
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up