我如何让Grails选择正确的JDK? [英] How do I make grails choose the right JDK?

查看:259
本文介绍了我如何让Grails选择正确的JDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Mac OSX 10.8.5以及Mac 1.6安装的Oracle Java 1.7。
我的路径前面有我的JAVA_HOME集和JAVA_HOME / bin。
当我从命令行运行grails编译时,我可以看到它选择的是Java 1.6而不是1.7。

I'm using Mac OSX 10.8.5 with Oracle's Java 1.7 installed in addition to the mac's 1.6. I have my JAVA_HOME set and the JAVA_HOME/bin in the front of my path. When I run a grails compile from the command line I can see it's choosing the Java 1.6 instead of 1.7. How do I make the grails command-line choose the JDK I want?

➤ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
➤ echo $PATH
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin /usr/local/share/npm/bin /Users/kbrodhagen/bin /Users/kbrodhagen/.rvm/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/local/git/bin
➤ set -x JAVA_OPTS "-showversion"
➤ grails compile
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)


推荐答案

您正在使用哪一个shell,以及您是如何设置 JAVA_HOME ?只要它对 grails 命令可见,Grails就应该尊重你的 JAVA_HOME 设置,例如在bash中你必须 export 变量,而不是仅仅设置它,在 tcsh 中,您可以使用 setenv set 。

Which shell are you using and exactly how did you set JAVA_HOME? Grails should respect your JAVA_HOME setting as long as it is visible to the grails command, for example in bash you must export the variable rather than just setting it, in tcsh you would use setenv rather than set.

$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home

您也可以移除 /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin 作为 / usr / bin / java 会自动委托给当前 JAVA_HOME 的相应 java 命令。

You can also remove /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin from your PATH as /usr/bin/java will automatically delegate to the appropriate java command for the current JAVA_HOME.

这篇关于我如何让Grails选择正确的JDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆