I have to use two versions of java (1.6.21 and 1.7).My company's code is dependent on 1.6_21 and we are planning to use artifactory. We are testing artifactory locally.But artifactory needs java 1.7 or higher.I want my default java home to point to 1.6_21 and for artifactory it should be 1.7.
But the problem is as soon as I install java 7,it sets itself as default.I have read many posts that explain how to manage two versions of java,but my artifactory and eclipse have to run at same time.
Please help!!
You'll need to use batch script (Windows) or a shell script (Linux) to execute artifactory, and set JAVA_HOME to the path of the Java version you want to execute
This better be on linux or else good luck.
Install java6
in /usr/java/java6/
and install java7
in /usr/java/java7/
Put something like this in your .bashrc
:
export JAVA_HOME=/usr/java/java6/
export PATH='$JAVA_HOME/bin:$PATH
alias java6='export JAVA_HOME="/usr/java/java6/"; export PATH="$JAVA_HOME/bin:$PATH"
alias java7='export JAVA_HOME="/usr/java/java7/"; export PATH="$JAVA_HOME/bin:$PATH"
Then open a terminal run java7
then start up artifactory for everything else you will be fine with 1.6.
来源:https://stackoverflow.com/questions/17412821/running-two-versions-of-java-at-same-time