0

i have macbook pro and have set java and java home. now it says that your JAVA_HOME is not set correctly. i want to completely remove java and install it again. how can i do this? Thanks.

5
  • 1
    You can set JAVA_HOME to /Library/Java/Home Commented Jan 31, 2011 at 11:57
  • Assuming you have a stock mac os x install wouldn't it be easier to fix your java_home instead? Commented Jan 31, 2011 at 11:58
  • try echo $PATH and check that what it will show Commented Jan 31, 2011 at 12:03
  • The current version of Mac OS X comes with Java preinstalled. Is there any reason why you're it installing it yourself? Commented Jan 31, 2011 at 12:13
  • @Erik : i tried that but couldn't get a good result. exactly i want to change my JAVA_HOME and i tried to do so, but it doesn't get changed. i didn't know what else i could do but to reinstall java on my mac Commented Jan 31, 2011 at 12:53

2 Answers 2

3

Put export JAVA_HOME=$(/usr/libexec/java_home) in your .profile and java_home will be set correctly.

Sign up to request clarification or add additional context in comments.

Comments

0

This sounds like a Java based tool like ant or maven not being able to locate the JDK.

It does not mean you have to reinstall Java (which by the way is pretty hard for OS X) but that you should set your environment variables properly.

For a one shot, just set

export JAVA_HOME=/Library/Java/Home

in your shell, and then run ant or maven in your shell.

3 Comments

i did that. and maven could locate it. but when i quit terminal and run it again maven gets confused. so i put the following in my .profile :
file: "export JAVA_HOME=/System/Library/Frameworks/JavaVM.frameworks/Version/1.6.0_22/HOME" but again when i quit terminal and run it again and type " echo $JAVA_HOME " it shows the wrong java home and maven gets confused again. i can't figure out what is wrong.
Then it is the wrong configuration file. Use .bashrc instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.