How to o run NetBeans Scala-built jar applications from the command line outside the IDE?

My program (written in Scala 2.8) works fine when launched using NetBeans. But when I try to run it from the outside, with "java-jar", it says "Exception in thread" main "java.lang.NoClassDefFoundError: scala / ScalaObject ...". The premises of all libraries, including Scala runtime inside the same directory as the running jar does not help. If I try to start the jar from Scala itself, it complains that it cannot decode it as utf-8 (it expects a Scala source, not a jar, I suppose). So how do I launch a Scala application?

UPDATE: for those who come here later with the same question, I would recommend reading the comments in response to barjak (including the ones that were hidden last), there is an answer. VonC also provides some interesting links on this topic.

+3
source share
2 answers

-jarand -classpathjava commands are mutually exclusive: you cannot dojava -jar YourScalaProg.jar -classpath scala-library.jar

If you want to run the application using java -jar, then the full class of the path should be specified in the Class-Pathjar manifest section .

You can run your application using only -classpath, for example java -classpath YourScalaProg.jar:scala-library.jar your.package.MainClass.

+4
source

Are you using scala-library.jar, as described in Adventures with the Scala message ?

java -classpath scala-library.jar:. YourClass

or

java -classpath scala-library.jar:yourApp.jar YourClass

YourClass scalac Scala .

scala-library.jar, SO jar Scala ( Scala code ").

+3

Source: https://habr.com/ru/post/1764409/


All Articles