2

This is my screen print:

[user@host ~]$ scala
Exception in thread "main" java.lang.UnsupportedClassVersionError: scala/tools/nsc/MainGenericRunner : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.findBootstrapClass(Native Method)
        at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:926)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: scala.tools.nsc.MainGenericRunner.  Program will exit.

But my java and javac version all updated to latest:

[user@host ~]$ javac -version
javac 1.8.0_162
[user@host ~]$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

My JAVA_HOME is set. And PATH is set with /path/to/scala/bin, /path/to/jdk1.8.0_162/bin and /path/to/jdk1.8.0_162/jre/bin.

What could be the issue?

yifei
  • 561
  • 5
  • 18
  • For Scala version scala-2.12.1, use Java 1.8 +. For Scala version 2.10.6, use java version 1.6+ (1.7 also works) – DAIRAV Apr 05 '18 at 06:15
  • does your PATH has both /path/to/jdk1.8.0_162/bin and /path/to/jdk1.8.0_162/jre/bin ? – DAIRAV Apr 05 '18 at 06:18
  • Does this answer your question? [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi) – Mark Rotteveel May 28 '20 at 12:39

1 Answers1

1

You are trying to compile in the higher version, and running in the lower version that’s why you are getting the error.

In intelliJ IDEA,

1.Go to maven Settings -> Maven -> lmporting. Set JDK for importer to 1.8

2.Go to Maven Settings → Maven → Runner. Set the JRE to 1.8.

3.Go to menu File* → Project Structure → SDKs. Make sure the JDK home path is set to 1.8.

Restart IntelliJ IDEA.

Raman Mishra
  • 2,635
  • 2
  • 15
  • 32
  • but running version 1.8.0_162 is already the latest java 8 version available? – yifei Apr 05 '18 at 06:58
  • Yes you are right but the thing is your jre is on lower version and jdk is on the upper version. So you need to point your jdk and jre to the same version. – Raman Mishra Apr 05 '18 at 07:02