3

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)

LuFFy
  • 8,799
  • 10
  • 41
  • 59
hammad
  • 117
  • 4
  • 11
  • 1
    The cause is exactly what you wrote in description, code compiled in java 8, run on java 7 – janek Aug 27 '16 at 14:30

1 Answers1

4

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.

Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
  • the problem is that i set the jJAVA_HOME but whenever i logout then connect back i found it not set again – hammad Aug 27 '16 at 14:31
  • This may help for this problem http://unix.stackexchange.com/questions/42032/how-to-set-environment-variable-java-home-that-will-be-saved-on-exit – Nicolas Filotto Aug 27 '16 at 14:39
  • i tried this but i have to re-do it over over whenever i connect – hammad Aug 27 '16 at 14:43
  • there is something wrong on how you do it because once done, it is set automatically when you connect. What is the target os? – Nicolas Filotto Aug 27 '16 at 14:44
  • You can use a JDK 8 to compile your code and have it run on JDK 7. You have to set the target class file version, for example when using maven, set the property `1.7`. – P.J.Meisch Aug 29 '16 at 12:50
  • Possible duplicate: https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi?rq=1 – Deepesh Rehi Jun 11 '18 at 07:47