score:48
If you define -jar the -classpath is ignored:
-jar When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
You can define the classpath dependencies in the Manifest metadata.
The easiest way to start your app is using the scala scripts:
scala -classpath target/scaaaaaaaaala-1.0.jar scaaalaaa.App Hello World!
score:0
Below is the way to execute the Scala Executable Jar
We need scala installed in your system.
Here first will give the jar path and jar name
If your code needs any dependency jar then keep all jar in one directory and give a path of this in command like below after the ":".
- At last give your class/object name.
scala -cp "/your/jar/path/jar_name.jar:/your/dependency/jar/path/*" SampleCode
score:4
For an executable jar, the classpath should be in the jar's manifest. For help on doing that, look through the answers to Stackoverflow: How to create an executable jar with dependancy jars.
score:6
Simply running
scala scaaaaaaaaala-1.0.jar
works for me with 2.11.6
score:6
use sbt-assembly
sbt plugin to produce a jar containing all dependencies
e.g. add a line in project/plugins.sbt
:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
adjust your build.sbt
e.g. with
mainClass in (assembly) := Some("mypackage.mysubpackage.MyMainClass")
assemblyJarName in assembly := "my_assembly.jar"
then build your assembled jar with
sbt assembly
and launch it with
java -jar ./target/scala-2.12/my_assembly.jar
Et voilĂ , no class-path this & thats needed any more. only 1 jar.
Source: stackoverflow.com
Related Query
- running scala apps with java -jar
- reuse running process with Java || Scala
- Running multiple Scala apps from one jar on JVM
- Running a jar with the right version of scala
- Running a scala program with the java tool / scala main function
- Running Scala Jar with Spark-Submit
- What's the standard way to work with dates and times in Scala? Should I use Java types or there are native Scala alternatives?
- Using Scala traits with implemented methods in Java
- Building a scala app with maven (that has java source mixed in)
- Base 64 encoding with Scala or Java
- How can I convert Scala Map to Java Map with scala.Float to java.Float k/v conversion
- Using a Java library with Scala reserved words
- Spark: How to map Python with Scala or Java User Defined Functions?
- Compiling Scala before / alongside Java with Gradle
- java try-with-resource not working with scala
- Why am I getting this error when running Scala 2.13 tests in IntelliJ, but not with Scala 2.12?
- comparing Scala lists with Java lists
- Intellij: SBT-based Scala project does not build with Java 9
- Using Scala with Java in Android Studio
- Why java complains about jar files with lots of entries?
- Best practices with Akka in Scala and third-party Java libraries
- Examples of Java frameworks which don't play well with Scala
- prompt for user input when running scala program with sbt
- Overriding Java interface with overloaded vargs methods in Scala
- Generically implementing a Java Single-Abstract-Method interface with a Scala closure?
- Implementing inner traits in Scala like we do with inner interfaces in Java
- Calling Java vararg method from Scala with primitives
- Scala 2.8: use Java annotation with an array parameter
- NoClassDefFoundError when running Scala jar file
- Is there a standard Scala function for running a block with a timeout?
More Query from same tag
- How to build spark application using Scala IDE and Maven?
- Enumerator vs Iterator in scala and java
- Scala: "class needs to be abstract, since method is not defined" error
- Spark Dataframe from a different data format
- Scala patternmatching: do nothing for some cases
- Generic way to implement a Pk Writes in Play Scala
- ensime sbt dependency issue
- Spark Scala Unit test getting failed
- code generation using Treehugger scala
- Play framework Application installation
- scala Futures: possible to find out if an 'onFailure' callback has been installed (so we can implement default error handling)?
- Find type class instances for Shapeless HList
- Last result of heavy processing of stream of events
- How does the && work in a foldleft scala
- Is there a way to route messages according to the stash size in Akka(Scala)
- Dataframes , check if column is spaces
- Hibernate subquery of String collection match
- Error in running Spark in Intellij : "object apache is not a member of package org"
- IntelliJ IDEA underlines my Scala code with implicits, but code works
- Executing system command in scala not working
- Convert Date to Timestamp in Scala
- Error replacing play.api.libs.concurrent.Promise with scala.concurrent.Promise
- Spark Dataframe ORDER BY giving mixed combination(asc + desc)
- Scala takeWhile Method with foldLeft and foldRight
- Regex for parse name with one or more words after double number and before 2 or more spaces
- Spark dataframe to nested map
- Play JSON Reads Error With Needed Implicits in Scope
- Accessing scala.None from Java
- Scala implicit for Option containing Map
- Mock for comprehension in scala