2

I recently upgraded to Yosemite and it's been nothing but problems related to java. First at startup of the OS (related to Adobe), and then at startup of Eclipse, it told me I needed to install Java 6. So I went and did that and things were better but then Eclipse wasn't working.

So I started poking around and it looks like Apple's install of Java is now Java 7 even though all the symlinks point to a folder named A (which is Java 7) but the symlinks are 1.4, 1.5, and 1.6. So I think eclipse was confused. So I decided to ditch Apple's Java and go get Oracle's.

So I get Oracle's and it installs to /Library/Java/JavaVirtualMachines/jdk1.7. However, all of Apple's java links in /usr/bin point back to Apple's Java. So to fix this I found this document:

http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html

But /usr/libexec/java_home doesn't exist anymore. So I update all the symlinks myself (not by editing the links in /usr/bin but by updating what they point to) so now when I do a javac it points to Oracle's JDK, as expected.

So thinking I fixed everything I then run ant, which was working before all this mess, and I get:

Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Trying the default build file: build.xml
Buildfile: /Users/rjcarr/Subversion/p/build.xml
Detected Java version: 1.7 in: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre
Detected OS: Unknown
parsing buildfile /Users/rjcarr/Subversion/p/build.xml with URI = file:/Users/rjcarr/Subversion/p/build.xml
Project base dir set to: /Users/rjcarr/Subversion/p
Caught an exception while logging the end of the build.  Exception was:
java.lang.NoClassDefFoundError: Could not initialize class sun.util.calendar.ZoneInfoFile
...
There has been an error prior to that:
java.lang.AssertionError: Platform not recognized

And this was the result whether I set $JAVA_HOME to the Oracle Java or not. What's going on?

These things happen to me every time I update OSX, but I always forget how much trouble I have. :)

UPDATE: Thanks for the help, I have some more information. I already had a couple JDK 7 from Oracle installed under /Library/Java/JavaVirtualMachines. It seems that everything in the A folder are just undercover symlinks to whatever the java_home returns. I had installed the latest JDK 7u71 and I think that was the culprit. I prematurely deleted the older JDKs I had and went to Oracle's archive to get my u51 back, but it wouldn't install because it thought OSX.10 was too old. So I made the leap and got JDK 8 and got past my ant problem but now I have new problems, including Eclipse won't even start. Yikes! Off to deal with that I guess.

rjcarr
  • 2,072
  • 2
  • 22
  • 35
  • `/usr/libexec/java_home` most certainly does still exist in Yosemite. It is a symlink `/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home` on my system. – Steve C Oct 23 '14 at 02:30
  • I'm not sure what symlinks you are referring to, or how you changed them. Leaving all of that stuff set to it's default config, did you try adding a JAVA_HOME variable to your .profile file? It's not clear which version of Java is desired, but for example: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7/Contents/Home – Sam Berry Oct 23 '14 at 02:53
  • I've personally never had to adjust symlinks related to jdk configuration on any mac, so it makes me curious if it is a necessary step... Then again I haven't updated to Yosemite yet :) – Sam Berry Oct 23 '14 at 02:55
  • @SteveC: My symlink isn't in libexec but it's where you state, so thanks! – rjcarr Oct 23 '14 at 05:35
  • @SamB.: Yeah, I agree, I recall the oracle installer fixing the symlinks before but for whatever reason it didn't this time. – rjcarr Oct 23 '14 at 05:36
  • Working thru similar issues here, I found this solution from @gregers to get Eclipse to recognize my newer JDK: [Eclipse Kepler for OS X Mavericks request Java SE 6](http://stackoverflow.com/questions/19563766/eclipse-kepler-for-os-x-mavericks-request-java-se-6). (Re. 10.10 too old) Can you believe the older Java installers think 10.10 < 10.7 (?!) – Xtopher Apr 21 '15 at 14:38

2 Answers2

1

If you need Java 6 on Yosemite then be sure to install it from the download available at Java for OS X 2014-001.

For Java 7, 8, etc then be sure to download the JDKs (as you are appear to be doing development work) from the Oracle Java Downloads web site.

Note that the JRE installation used for web browser applets is managed and installed differently (and in a different location).

Steve C
  • 18,876
  • 5
  • 34
  • 37
  • That's right, when I started the computer or eclipse it would tell me I needed java 6 and that's where I got it from. And for Java 7, as I said, it seems there was an Apple install of it, which is where all of the /usr/bin links were pointing. I also installed Oracle's Java 7, but the installer didn't fix the /usr/bin links like I recall it doing in the past. – rjcarr Oct 23 '14 at 05:39
  • There has never been an "Apple" install of Java 7. Is it possible you installed one of the early OpenJDK builds? Otherwise it came from Oracle. – Steve C Oct 23 '14 at 05:50
  • I think you're correct, it seems that the java that is in the A directory just opens whatever is listed using java_home and that A directory is just a bunch of undercover symlinks. – rjcarr Oct 23 '14 at 06:41
0

If you need Ant too, install it from the official Apache Ant site: binary downloads

If you are already using Homebrew use that to install Ant.

This question is somewhat related to missing ant mavericks on stackoverflow

Community
  • 1
  • 1
Michel
  • 1,395
  • 13
  • 14