1

今天我安装了 cygwin,我正在检查我的 JAVA HOME 和其他设置,我发现了非常奇怪的事情..

当我这样做时echo $JAVA_HOME,我总是会得到C:\Java\jdk1.6.0_26很好的结果,这也是我已经jdk1.6.0_26在环境变量中设置的值,但是当我执行 java -version 时,我总是得到不同版本的 java,我总是看到 1.7..

uname@D-PHC-22334455 /cygdrive/c
$ echo $JAVA_HOME
C:\Java\jdk1.6.0_26

uname@D-PHC-22334455 /cygdrive/c
$ which java
/cygdrive/c/WINDOWS/system32/java

uname@D-PHC-22334455 /cygdrive/c
$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode)

我已经检查了我的 PATH 变量和 JAVA_HOME 。两者都指向 jdk1.6 谁能解释发生了什么错误?

下面是我的 PATH 变量-

uname@D-PHC-22334455 /cygdrive/c
$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/Java/jdk1.6.0_26:/cygdrive/c/Program Files (x86)/DataStax Community/python:/cygdrive/c/Users/uname/openssl/bin:/cygdrive/c/Python27:/cygdrive/c/Python27/Scripts:/cygdrive/d/app/uname/product/11.1.0/db_1/bin:/cygdrive/c/apache-maven-3.0.4-bin/apache-maven-3.0.4/bin:/cygdrive/c/Program Files (x86)/IBM/RationalSDLC/Clearquest/cqcli/bin:/cygdrive/c/Perl64/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Perl64/bin:/cygdrive/c/Program Files (x86)/Perforce:/cygdrive/c/Program Files (x86)/IBM/RationalSDLC/ClearCase/bin:/cygdrive/c/Program Files (x86)/IBM/RationalSDLC/common:/cygdrive/d/ede-5.1.1/apache-ant-1.7.1.2008.06.27/bin:/cygdrive/c/Program Files (x86)/Git/cmd:/usr/bin:/cygdrive/c/Program Files/Common Files/Hitachi ID:/cygdrive/c/Eclipse-C++/MinGW:/etc/alternatives:%APPDATA%/Python/Scripts
4

2 回答 2

2

所以安装的Java必须Java 1.7.0_25如它所说

uname@D-PHC-22334455 /cygdrive/c
$ which java
/cygdrive/c/WINDOWS/system32/java

即使你PATH点到C:\Java\jdk1.6.0_26

/Windows/system32总是首先搜索。

于 2013-09-27T17:37:56.510 回答
0

你为什么不尝试重命名java文件然后/cygdrive/c/WINDOWS/system32/java再次/cygdrive/c/WINDOWS/system32/java.back添加(如果它仍然不起作用)路径的java路径:
export JAVA_HOME="/cygdrive/c/Java/jdk1.6.0_26"
export PATH="$PATH:$JAVA_HOME/bin"

于 2016-08-26T12:44:52.080 回答