Wednesday, 13 December 2017

java - unsupported class version error in spark submit

itemprop="text">

Trying to run spark application which
I build using maven and jdk1.8 on a remote machine in which installed Java version: jdk
1.7.
Using spark-submit
command:



./bin/spark-submit
--class myapp.Main --master local[*] /home/mbala/myJars/CDCJar/myapp-0.0.1-SNAPSHOT.jar
/home/mbala/myJars/CDCJar/previous.csv /home/mbala/myJars/CDCJar/source.csv
/home/mbala/fer


Getting
below exception:






Exception in thread "main" java.lang.UnsupportedClassVersionError: myapp/Main :
Unsupported
major.minor version 52.0
at
java.lang.ClassLoader.defineClass1(Native Method)
at
java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at
java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at
java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at
java.net.URLClassLoader$1.run(URLClassLoader.java:361)

at
java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at
java.security.AccessController.doPrivileged(Native Method)
at
java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at
java.lang.Class.forName0(Native Method)
at
java.lang.Class.forName(Class.java:274)
at
org.apache.spark.util.Utils$.classForName(Utils.scala:225)
at
org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:686)

at
org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:185)


at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:210)
at
org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:124)
at
org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)




Answer




If you build a Java
program with a Java Development Kit 8, you need a
Java Runtime of at least 8 to be
able to run it, otherwise you get this exception. Upgrade the version of java on your
remote machine or build with a JDK 7 instead to avoid such kind
of issue.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...