0

I have a Mac Mini with java 8 installed. And at the command shell, if JAVA_HOME is set, all java commands hang indefinitely.

Anyone know why this is and how to fix it?

$ uname -a
Darwin myhostname 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

$ set | grep JAVA_HOME
### no output - JAVA_HOME is not set ###

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

$ which java
/usr/bin/java

$ ls -l /usr/bin/java
lrwxr-xr-x  1 root  wheel  74 Jan  8  2015 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

$ ls -l /System/Library/Frameworks/JavaVM.framework/Versions/Current/bin
lrwxr-xr-x  1 root  wheel  8 Jan  8  2015 /System/Library/Frameworks/JavaVM.framework/Versions/Current/bin -> Commands

$ /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/Current

$ java -version
### hangs here ###
Zdenik
  • 406
  • 1
  • 4
  • 13
  • No, but thanks anyway. I'm having trouble with java hanging when JAVA_HOME is set, I'm not having trouble figuring out how to set JAVA_HOME. – Zdenik Mar 18 '16 at 20:02
  • What I am suggesting is that you don't have JAVA_HOME set *correctly*. Have you tried the accepted answer on that question? – dcsohl Mar 18 '16 at 20:04
  • Ah, I see. When I set JAVA_HOME to /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home, which is the output of /usr/libexec/java_home, java doesn't hang. So that gets around the problem, thank you. But I'm still left wondering why the other directory is apparently wrong, even though it is clearly the location pointed to by the /usr/bin/java link and running java out of that directory works just fine. – Zdenik Mar 18 '16 at 20:20
  • I should also point out that setting JAVA_HOME to some random value also doesn't cause java to hang. So to rephrase my question more specifically: why does java hang when JAVA_HOME is set to the location containing the bin/java executable that's actually being run? Since your answer provides me with a working solution I'm in no great need of an answer. But I'd still like to know what's going on in case it has any bearing on future problems. Plus I just like to know what's going. – Zdenik Mar 18 '16 at 20:33

0 Answers0