ClassNotFoundException / NoClassDefFoundError when running a Scala jar

Having a Scala project exported to a .jar with eclipse, the application started with java -jar app.jar dies with the error java.lang.ClassNotFoundException: scala.Predef$.

Full output:

Exception in Application start method
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:490)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:829)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:56)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:150)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: scala/Predef$
    at main.App$.debug(App.scala:69)
    at main.App.start(App.scala:23)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:772)
    at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:260)
    at com.sun.javafx.application.PlatformImpl$5$1.run(PlatformImpl.java:223)
    at com.sun.javafx.application.PlatformImpl$5$1.run(PlatformImpl.java:220)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:220)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:94)
Caused by: java.lang.ClassNotFoundException: scala.Predef$
    at java.net.URLClassLoader$1.run(URLClassLoader.java:365)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:353)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:422)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:355)
    ... 9 more

The referenced line at main.App$.debug(App.scala:69):

object App {
//...
    def debug(s: String) {
        println("DEB: "+s)
    }
// ... 
}

This seems to be caused because the Scala libraries are not contained in the jar. How do I fix this?

I have read about solutions with maven plugins but I would prefer a manual option.

Answers


Manually push the libs there in jar.. or you have good option to script it down


Need Your Help

Updating an image contained in a JLabel - problems

java image swing jlabel

The part of the application that I am currently having trouble getting to work is being able to scroll through and display a list of images, one at a time. I'm getting a directory from the user,

Send 3 javascript arrays to c# server side code

c# javascript client

I am fetching an XML format data and assigning it to a treeview. The XML Data has an ID attribute attached to it. On client side I am getting all the selected nodes of the treeview. I am able to fe...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.