Ok if i try run a java file from console i get unsupported major.minor 51.0. These class files were't compiled on my MAC osx. BUT... If I'm in finder and right click the class file and open with jar launcher it loads. Im trying to load it with terminal, java programName. My java version in console says
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
BUT in sys-pref-java it says Platform: 1.7 product: 1.7.0_51
Terminal using a different version? Not sure what to do.
You should set your JAVA_HOME environment variable to the results of the /usr/libexec/java_home command (which evaluates to your system configured Java version).
Try this:-
export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)"
Related
I use macOS Sierra. When I do:
java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
it seems that my java version is 1.6.0.
But when I look at System Preferences I find that my version is Java 8 Update 144. I want to use an R package that needs Java >=8.0. What have I done wrong?
The Java found in your command line is the one used to compile when using command line, first, try export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) then check if the correct version shows up using java -version if not reinstall the newest java and run the command again
Everyone!
I have a java program with jar libraries that works on the following JDK version:
java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
I need to make it compile on a supercomputer that works on the following JDK version:
java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
As you can see they all have the same JDK which is JDK 8. However, when compiling using:
javac myFile.java
The following error appears:
class file has wrong version 51.0, should be 48.0
It seems that the compiling is done on another JDK (other than 8). Can anyone please help me solve this problem?
Kindest Regards!
java.lang.UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime.
J2SE 8=52,
J2SE 7=51,
J2SE 6.0=50,
J2SE 5.0=49,
JDK 1.4=48,
JDK 1.3=47,
JDK 1.2=46,
JDK 1.1=45
First Rule: Java version must be same on your local pc and server. Otherwise this kind of unwanted problem may arise.
For more checking, You can check
java --version
javac --version
It will make clarify of jdk and jre version mismatch. If it shows various version, then uninstall other versions and build your project and deploy on server.
Another answer is similar to your problem is here: Cannot compile Java code - "class file has wrong version 52.0, should be 48.0"
Resource Link:
Exception in thread “main” java.lang.UnsupportedClassVersionError: com/crunchify/Main : Unsupported major.minor version 51.0
I'm trying to run PUMA benchmark set(Purdue Mapreduce Benchmarks Suite: for hadoop). I ran one application(wordcount) appropriately but couldn't run the other one(invertedindex). Error occures at runtime and it says
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/examples/InvertedIndex : Unsupported major.minor version 51.0
I googled and found that it's because of the java version. I checked the java version and recompile the code and then run it. But still the same error occured at runtime for invertedindex application and wordcount application works well.
$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
$ javac -version
javac 1.7.0_51
How can I resolve this problem? Can this error be caused by source code?
the java version you obtain with java -version is not reflective of your hadoop's java version.
to check your hadoop's java version, use command hadoop classpath and check the directory of jdk it points to. or you could go to hadoop/config/hadoop-env.sh to find it.
your problem will most likely be solved by pointing hadoops's java home to jdk 1.7. you can edit this again in hadoop-env.sh.
I am getting this error when compiling a project: Unsupported major.minor version 51.0. I am using JDK 1.6:
$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
According to this page, the error is due to inconsistency between JRE and JDK. Does anyone know how to fix this? Thank you very much.
BTW, my platform is OSX 10.8.5.
Update
Here is my JAVA_HOME:
export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0`
You are getting "Unsupported major.minor version 51.0" because you are trying to run the application in jre 6 which is compiled using jdk 7.
Either compile your application using jdk 6 or upgrade your default jre to 7.
I installed Java 7 on my Mac, compiled a web-app, and now I am trying to run it on Tomcat. However, I get the nasty Unsupported major.minor version 51.0 error. Googling showed that it is because Tomcat is using Java 6 to run the app, which is compiled for Java 7.
So I tried setting the path to the Java 7 jre in my "catalina.sh" script, but it didn't help. Moreover, "java -version" returns the correct java version.
dtv$ java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
How can I fix this?
Try setting JAVA_HOME environment variable to point to your JDK 7. Catalina expects to find Java there. See if that tells it how to get JDK 7.