如何在Mac OS X 10.7.5上还原为Java 1.6 [英] How to Revert to Java 1.6 on Mac OS X 10.7.5
问题描述
我有1.6安装程序.我用过了它不会更改我的Java安装,也不会说有较旧的版本,但是可以完成安装.
I have the 1.6 installer. I've used it. It does not change my Java installation, nor say there is an older version, but it does complete the installation.
我一直在使用符号链接,但是不管我做什么,都运行
I've been working with the symlinks a bit, but no matter what I do, running
java -version
终端中的
始终会导致
in terminal always results in
Daves-MacBook-Pro:core-server dave$ java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
我的应用程序可与GAE一起使用,而GAE完全不使用Java 1.7.因此,我无法使用1.7编译我的代码!我必须使用1.6,但是我没有找到删除1.7的方法或以其他方式强制在1.6上进行构建/编译.
My application works with GAE, which does NOT use Java 1.7 at all. As such, I cannot compile my code using 1.7! I have to use 1.6, but I have failed at finding a way to remove 1.7 or otherwise force build/compiling to occur on 1.6.
最后一点,我在命令行上运行构建工具,因此在Eclipse中更改项目设置似乎无济于事.
A final note, I am running a build tool on the command line, so changing the settings of the project in Eclipse does not seem like it will help.
推荐答案
java
,javac
等命令行工具对JAVA_HOME
环境变量的值敏感,如果此变量使用1.6指向1.6 JDK.工具/usr/libexec/java_home
在这里是您的朋友.正在运行
The java
, javac
, etc. command line tools are sensitive to the value of the JAVA_HOME
environment variable and will use 1.6 if this variable points to a 1.6 JDK. The tool /usr/libexec/java_home
is your friend here. Running
/usr/libexec/java_home
将为系统上最新的JDK打印适当的JAVA_HOME
值.这将是Java 7,但是您可以使用-v
标志来应用约束,例如
will print out the appropriate JAVA_HOME
value for the most up to date JDK on your system. This will be Java 7, but you can apply constraints using the -v
flag, for example
/usr/libexec/java_home -v '1.6*'
将为系统上最佳的 1.6 JDK返回JAVA_HOME
值.您可以使用此值设置JAVA_HOME
:
will return a JAVA_HOME
value for the best available 1.6 JDK on your system. You can use this value to set JAVA_HOME
:
export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`
通过将以上行添加到主目录中的.bash_profile
文件中,将
一次性地用于特定的终端会话,或者永久地用于所有将来的终端会话.
either as a one-off for a particular Terminal session, or permanently for all future terminal sessions by adding the above line to the .bash_profile
file in your home directory.
$ export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`
$ java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
$ export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`
$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
这篇关于如何在Mac OS X 10.7.5上还原为Java 1.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!