0

I'm trying to generate a libgdx project using "project generator" but it shows this error:

ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

But I have installed the JAVA 1.8, using the terminal command it shows this:

$ java -version

java version "1.8.0_101"  
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)    
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

So how to setup the right jvm, someone have any suggestion or the solution to correct this issue?

Synapsido
  • 140
  • 3
  • 12

2 Answers2

2

I believe you are using unix type operating system. If so do the following steps :

echo "export JAVA_HOME=`/usr/libexec/java_home`"

If it prints empty like below

JAVA_HOME=

then you should install java first from oracle site : https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html

If it prints like this :

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

Then you should set your Java Home path like following way :

export JAVA_HOME=`/usr/libexec/java_home`

Please check this out. This link might give you lucid view to set Java Home to valid path.

mac os how to set java home correctly

Hope this knowledge sharing helps you. Thanks

Queendevelopers
  • 183
  • 3
  • 20
atiqkhaled
  • 386
  • 4
  • 19
0

What happens when you type this command in terminal: echo $JAVA_HOME

If that is showing the older version of java, you will just need to update your JAVA_HOME settings.

Set JAVA_HOME using this command in Terminal: export JAVA_HOME= path to JDK

echo $JAVA_HOME on Terminal one more time to confirm the path was changed.

One other thing to keep in mind is sometimes, depending on the programs/projects, you could run into an issue between 32 and 64 bit versions. You might want to doublecheck you are using the right one.

Will Smith
  • 16
  • 1
  • 1
    It shows: ERROR: JAVA_HOME is set to an invalid directoryDone! and the **echo** shows: **/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk** – Synapsido Jan 04 '17 at 19:24