Unable to execute the program in hadoop - java

When I created a Jar and compiled in windows and tried to run in Hadoop. It's throwing an error while running this script
admin1#admin1:/usr/local/hadoop/conf$ hadoop jar wordcount.jar com.shailu.wordcount.WordCount input/wordcount output/wordcount
Error is:
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/shailu/wordcount/WordCount : Unsupported major.minor version 52.0

Nothing wrong with ur execution,
Looks like there is a mismatch in the compile and the execute environment.
type "java -version" in both the environments , i.e. windows and hadoop(linux/unix)
My doubt is you have compiled the code in a higher version like 1.8, change it to 1.7 or so, you should be ok.
or while compiling choose the same java version as the hadoop environment have.

I have encountered such problem. You need keep the compiler consistently between windows and hadoop or hadoop compiler higher than windows'. See picture I screenshot from Internet(contain a little Chinese, you also can refence this website if you can open it: JDK compiler version mapping minor.major). I guess JDK1.8.x is mapping major.minor version 52.0.
JDK编译器版本-------------JDK compiler version
target参数----------------target parameter
十六进制 minor.major------hexadecimal minor.major
十进制 minor.major--------decimal minor.major
不能带 target 参数--------can't add target parameter
默认为--------------------default

Related

i tried to update my jdk but didn't fix it (Visual studio code) 1.38 version

I compiled a java file and tried to launch it with javac but it doesn't work. I tried to update JDK to the newest version, but received this error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has
been compiled by a more recent version of the Java Runtime (class file version
56.0), this version of the Java Runtime only recognizes class file versions up
to 52.0
When you call java, us the full path to the java executable, as follows:
On Windows:
C:\...\Java12\bin\java.exe my.class
On Linux:
/opt/java12/bin/java my.class
Adjust path according to your environment.

"A Java Exception has occured" what might be the cause?

When my jar is run on another computer there occurs a java exception but on my setup it runs ok. They are using Java 1.8? atleast one of them is. and my JDK is also 1.8.
Could the cause of this be in META-INF? I also tried sending .class files and running the main class using cmd (it maybe gave some other error i think)
Also I've exported it as a jar from eclipse, not executable jar. Could this be the cause?
EDIT
One of the stacktraces says: "Unsupported major.minor version 52.0‏"
Java version mismatch. The other computer not really running with JRE 8.
See this answer for detail Unsupported major.minor version 52.0
Your code was compiled with Java Version 1.8 while it is being executed with Java Version 1.7 or below.

UnsupportedClassVersionError when running Ant from eclipse

I'm trying to run an ant script from eclipse but it fails with the following message:
BUILD FAILED
project_path/build.xml:5:
java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main :
Unsupported major.minor version 51.0
However, when I run this from command line (./ant) it runs as expected.
Environment info:
OS: Linux Mint 64
Eclipse: Juno (4.2.1)
JDK: Oracle 1.7.0_11
Ant (command line): 1.8.2
I've also set the "Ant Home" (within eclipse settings) to be the same as the one I use from command line.
I've searched a lot on this issue but I can't seem to find anything that helped, I can try to uninstall all java (jdk/jre) I currently have installed, and then reinstall java 7, but I prefer not to take this route.
Any ideas?
Thanks!
UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 51.0
This suggests there's some mix up between versions - Ant is trying to run the Java 7 javac on a Java 6 JVM. Have a look at your project properties, builders, Ant Builder, and check the classpath section. On my Eclipse with a newly-created Ant Builder I have the tools.jar from my 1.7 JDK listed under user entries -> additional tasks and support. If you have the same, but your Eclipse is itself running on Java 6 then it won't work. You can find out which Java Eclipse itself is running on via the "about Eclipse" box under installation details -> configuration. This may not be the same as the version of Java that your project is configured to use.
Another thing that might fix it is to go to the JRE tab in the ant builder settings and tell it to run in a separate JRE rather than running within the Eclipse process.
Your Eclipse ant task is trying to run the Java7 JDK compiler using a pre-Java7 JDK/JRE. Make sure you use a Java7 JRE to run Eclipse.
generally if you compile Java program in Java 1.7 it will create class file with major version 51.0 and if you run that on lower java version you will get
java.lang.unsupportedclassversionerror unsupported major.minor version 51.0
check this post for more details on the same

Errors when running executable jar file

I get the error below when trying to run an executable jar file. The file only contains a main with one line "System.out.println("Woo!");" and runs fine in eclipse.
I'm not sure how to read these error messages.
(too new to post images correctly)
The error means that you have compiled the code with a higher version of java and trying to run it on a older version of jvm.
Since it says major.minor version 51.0 it means that your compiler is java6. So you should run your program on java6 or higher.
Your compiled class is in jre 1.5 and your system default jre is different(might be 1.6).
compile your code in same version of jre.

Google App Engine Java Error

I just started off with Google App Engine 1.6.4 in Eclipse Indigo a couple of days ago and I face a problem with the back end.
Whenever I try to use a servlet or a JSP, I get this annoying
java.lang.UnsupportedClassVersionError: org/msamogh/MyServlet : Unsupported major.minor version 51.0
I tried changing my JRE to Java 6, but the error still remains. Does anyone know how to fix this.
The major.minor version 51.0 seems to indicate that your classes are compiled using Java 7. Please make sure that the following are done:
Start Eclipse using a Java 6 JDK.
Set the default JVM in Eclipse to a Java 6 JDK.
Set the default and/or project compiler settings to use 1.6 target.
In general, you need to make sure that your runtime JRE is able to understand your compiled code. If you try to run code compiled for 1.7 on a 1.6 JRE, you will get the above error.
What is your output when you do java -version? This will tell you what version the running JVM is.
The Unsupported major.minor version 51.0 error could mean:
app is running on a lower Java version then the one used to compile it
Try adding a SYSTEM VARIABLE that looks like this: JRE_HOME = C:\PROGRAM FILES\JAVA\JRE7 or JRE6 shipped with the JDK 1.7 or later package with which you compiled it.

Categories

Resources