I really struggle with that. I was not able to configure Intellij to use Javac, unable to start javadoc. I just can't seem to have my Java runtime stable and productive on Mac OSX.
I created the simplest example, which is the world hello program, and still errors from the command line. Everything I read about this error tells me to “update the compiler”. But I'm really not sure what the problem is: javac and java are running 1.8 (now, after I tried updating the JVM system).
I explicitly set the path when calling javac, checking version, etc. Everything tells me about it 1.8.
Can anyone explain how to fix this? (without returning my system to 1.5 SDK).
This is inferred from the main hello world application:
$JAVA_HOME/bin/javac Main.java
Main.java:3: cannot access java.lang.Object
bad class file: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/rt.jar(java/lang/Object.class)
class file has wrong version 52.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
public class Main {
^
1 error
localhost:mycompany$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
localhost:mycompany$
Exiting javac version:
javac -version
javac 1.8.0_45
javac: no source files
Usage: javac <options> <source files>
Exiting java version:
java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
source
share