osx java home_找不到 JAVA_HOME on Mac OSX

I recently switched my Java versions from 1.5 to 1.6 and I’ve been

hitting some issues with the java path.

I tried setting the environment

variable JAVA_HOME=/usr and

that worked for some stuff but I still saw this error when running

java.

eg:

>java

-version

Unable to find a $JAVA_HOME at "/usr", continuing with

system-provided Java

I solved the problem by doing the following.

First I found out where java actually was with:

>ls -l'

`which java`

/usr/bin/java ->

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

I noticed a command called java_home in that same directory.

Running that command yields the correct java home directory.

>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

To correctly set the my JAVA_HOME environment variable in future, I

added the following to my~/.profile

export

JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`

Once you have done this you can restart your terminal window or

run >.

~/.profile to reload you profile into the

current terminal session.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值