今天我安装了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
答案 0 :(得分: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
。
答案 1 :(得分: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"