How to create a jar from some Scala source code?

How to create a jar from some Scala source code? I want to use part of this code in my Clojure project.

Is there an easier way than making batch files like in this SO question ?

Thanks Alex

+4
source share
4 answers

Scala doesn't really matter when it comes to what you do with the .class files created by its compiler. Just use the jar command with the action flag c .

However, when starting a program that uses the Scala-compiled .class files, you will need to have the scala-library.jar in the path class. And be careful to use scala-library.jar for / from the same Scala Development Kit that was used to compile the Scala source. There is currently no binary compatibility between versions for Scala-generated .class files.

+7
source

One way to create a β€œ.jar” might be β€œeasier” is to use the simple-build-tool , which supports package * and takes quite a bit of time to configure and use.

+4
source

You can use maven scala plugin or buildr .

+2
source

It really helped

If you are using eclipse just export the project as a jar file

goto file -> Export -> java -> as a jar file

Just add more explanation:

  • Install scala eclipse from typesafe
  • Once you are done coding, export as a jar (file -> Export -> java -> as a jar file).
  • from the command line, you can run java -cp path_to_dependancies: your_newly_generated_jar :. your_main_object_name.

NTN.

+1
source

All Articles