问题描述:

I am trying to install Java 7 on my Ubuntu 14.04 system. I have downloaded the package in oracle, jdk1.7.0_80, which contains all the tools in bin folder.

Here comes my question. I want to switch the version of my tools to match the tools in bin folder in jdk1.7.0_80. Like java, jar and javac, whenever there exists a tool in /usr/bin, OS will automatically map the tool to my jdk bin folder. Does anyone has idea on this?

Thanks,

Xianan

网友答案:

Here is how you should install java alternatives

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.7.0_45/bin/java" 1
sudo update-alternatives --set java /usr/local/java/jdk1.7.0_45/bin/java
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_45/bin/javac" 1
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_45/bin/javac

If you need full JRE with the web plugin you can use

sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.7.0_45/bin/javaws" 1
sudo update-alternatives --set javaws /usr/local/java/jdk1.7.0_45/bin/javaws

You can check whats available and switch between installed java versions using

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
相关阅读:
Top