Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException:scala.PreDef$ issue

I am trying to package a simple executable Jar written in Scala, through Eclipse's Export function.

When attempting to execute the Jar from cmd java -jar test2.jar

I get the following error. Any ideas? Thank you.

Caused by: java.lang.NoClassDefFoundError: scala/Predef$
        at Parser.Test(Parser.scala:5)
        at Main.main(Main.java:12)
        ... 5 more
Caused by: java.lang.ClassNotFoundException: scala.Predef$
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 7 more
like image 768
Andy Avatar asked May 29 '13 19:05

Andy


2 Answers

You just need to add the scala library jar to the classpath.

You can do it like this (assuming that the "scala-library.jar" jar is in the current directory) :

java -cp scala-library.jar -jar test2.jar

The documentation for tha java comamnd can be found here: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html

like image 61
Régis Jean-Gilles Avatar answered Nov 19 '22 08:11

Régis Jean-Gilles


for me i was using jdk 11 and scala library container 2.12.3 and when i changed to jdk 8 it works fine it is because of jdk11 scala version support JDK Compatibility

right click on the project , Build path ,configure Build path , edit your jdk to less than 11

like image 25
Shaaban Ebrahim Avatar answered Nov 19 '22 08:11

Shaaban Ebrahim