Hadoop: unsupported major.minor version 52.0 [duplicate] - java

This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 2 years ago.
Before you read my question, you should know that it's not a duplicate to all other similar questions on Stackoverflow that I already read!
I've developed (and built and compiled) a Hadoop program on Windows 10 (development machine) using Eclipse. The program reads WARC files and rewrite them in JSON format. It uses these classes to override the Writable format:
WarcFileInputFormat.java
WarcFileRecordReader.java
WritableWarcRecord.java
I added hadoop- 2.6.0 jars files to my project.
This is the java version of development machine:
$java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
I tested my code on Ubuntu 14 machine (testing machine) and it just worked perfectly. this machine has hadoop- 2.6.0:
Hadoop 2.6.0
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r e3496499ecb8d220fba99dc5ed4c99c8f9e33bb1
Compiled by jenkins on 2014-11-13T21:10Z
Compiled with protoc 2.5.0
From source with checksum 18e43357c8f927c0695f1e9522859d6a
This command was run using /home/username/hadoop-2.6.0/share/hadoop/common/hadoop-common-2.6.0.jar
This is the java version of testing machine:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
I moved to a CentOS oracle server and ran my program. This server has the same java version as my development machine:
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
and it had this Hadoop version:
Hadoop 2.6.0-cdh5.13.1
Subversion http://github.com/cloudera/hadoop -r 0061e3eb8ab164e415630bca11d299a7c2ec74fd
Compiled by jenkins on 2017-11-09T16:37Z
Compiled with protoc 2.5.0
From source with checksum 16d5272b34af2d8a4b4b7ee8f7c4cbe
This command was run using /opt/cloudera/parcels/CDH-5.13.1-1.cdh5.13.1.p0.2/jars/hadoop-common-2.6.0-cdh5.13.1.jar
On this server I got the following error for each job:
18/02/23 11:59:45 INFO mapreduce.Job: Task Id : attempt_1517308433710_0012_m_000003_0, Status : FAILED
Error: data/warc/WarcFileInputFormat : Unsupported major.minor version 52.0
Here are the things I tried and they didn't work:
Adding the WARC readers' classes to my project as classes not as a jar to build them using the correct java version.
Changing Hadoop jar files version from hadoop- 2.6.0 to hadoop- 2.6.0-cdh5.13.1
Using mapred instead of mapreduce as the reader classes are using mapred
I'm not sure what exactly causes this issue especially that it points to the class WarcFileInputFormat.java that I didn't write but added to my project from the link I provided above. What surprised me is that the program worked perfectly on Ubuntu machine that has a lower java version, but didn't work on the CentOS server that has the same java version as the Windows development machine!
Any hints?

The problem was that Cloudera uses a lower version of JAVA:
/usr/java/jdk1.7.0_67-cloudera/bin/java

I had the same error message as yours, it occurred to me when I was implementing a Hive UDF.
I saw your answer and I tried Java 1.7 instead of 1.8 to build the JAR file of the UDF, and it worked.
I was using Cloudera Quickstart VM and it has JAVA_HOME set to Java 1.7

Related

Should versions of java & javac be same in the system?

Should java & javac version be same in the system?
as I am having java -version
java version "1.8.0_251" Java(TM) SE Runtime Environment (build
1.8.0_251-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
and javac -version
javac 1.8.0_181
Is there any issue if it's not the same version?
Should java & javac version be same in the system?
Not really, you can have as many java version as you want on one system, as long as you know which version you use when compiling or running application. If you have multiple java version in your system, be aware which version you put on your PATH environment variable to avoid a miss.
Your problem should be caused by multiple entry in your PATH environment variable that refering to java installation directory that has different version (note, java can be found in JDK and JRE installation, while javac can only be found in JDK installation).
Is there any issue if it's not the same version?
There should be no issue, as long as you don't use features that can only be found on the java version you use when compiling the program. In your case, the different is in build version, it's okay.

Elasticsearch fails to run on the java version 1.8 on CentOS 7

I have downloaded the elesticsearch on the CentOS 7 server.
This server has the following version of java:
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)
When I run the bin/elasticsearch it fails with the following error:
Error: Could not find or load main class org.elasticsearch.tools.JavaVersionChecker
Elasticsearch requires at least Java 8 but your Java version from /bin/java does not meet this requirement
As you can see It says that it can't find the java 8.However the java -version indicates the current java version is 1.8.
I have tried a lot but can't solve this.
Please help me.

JDK Wrong Version

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

Sencha Cmd installation on Mac: Java not found

Trying to install Sencha Command 3.1.1 on my iMac (10.8.3). The installer is saying:
The installer could not find a valid Java(tm) on this machine.
Supported versions: Vendor : Any min. 1.6.0 max. any
Following another Stack Overflow thread, I tried linking /usr/bin/java to /Library/Internet Plugins/JavaAppletPlugin.plugin/Contents/Home/bin/java. Now, I get this on the command line:
~ ๐Ÿ” java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
So that looks good, but the installer still complains that it cannot find Java. Why can't it?
What eventually fixed this for me, after consulting with Sencha support, was installing the full JDK rather than just the JRE. I don't know exactly why this fixed it, or what the root cause was, but now Command installed successfully and is working fine.
I had JDK installed, but one thing worked for me was exporting $java_home/bin:
export PATH=$JAVA_HOME/bin:$PATH

Can't run webapp on Tomcat, Error 51, although java -version is correct, Mac OS X

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.

Categories

Resources