Running two versions of java at same time [closed]

徘徊边缘 提交于 2019-12-04 05:28:48

问题


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!!


回答1:


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




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!