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?

3

1 Answer 1

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.

2
  • but running version 1.8.0_162 is already the latest java 8 version available?
    – yifei
    Commented Apr 5, 2018 at 6: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. Commented Apr 5, 2018 at 7:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.