Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA_HOME is not defined correctly Error while compiling

Tags:

java

macos

cocoa

I am developing an aplication in cocoa which uses some java classes .I am getting an error "JAVA_HOME is not defined correctly We cannot execute /System/Library/Frameworks/JavaVM.framework/Home/bin/java".I dont know how to resolve this..Please anyone help me..

Thanks in advance

like image 261
MobX Avatar asked Jan 27 '10 09:01

MobX


3 Answers

export JAVA_HOME=`/usr/libexec/java_home` is exactly what you want to do.

In fact, all of the Apache projects (well, any project really) that hardcodes /System/Library/Frameworks/JavaVM.framework/Versions/... needs to use /usr/libexec/java_home if it exists. It's the only way you will know if Java is actually installed.

At some point in the future the symlinks in /System/Library/Frameworks/JavaVM.framework/Versions/ will be going away, which will even more severely break these projects if they want to load using an Oracle/OpenJDK JVM.

like image 31
Alex Avatar answered Sep 28 '22 03:09

Alex


In your .bashrc file, add below lines:

export JAVA_HOME=/usr
export PATH=$PATH:$JAVA_HOME

This worked for me.

like image 81
Shrutee Avatar answered Sep 28 '22 05:09

Shrutee


Add the following line to ~/.mavenrc file

export JAVA_HOME=$(/usr/libexec/java_home)

Reference: Maven ignoring JAVA_HOME on OSX?

like image 43
shaunthomas999 Avatar answered Sep 28 '22 05:09

shaunthomas999