Reputation: 11433
I'm playing around with including Scala in my Java project.
I noticed that IntelliJ includes all of the following jars (extracted) in the generated runnable jar artifact:
scala-library-2.12.2.jar
scala-library-2.12.2-sources.jar
scala-reflect-2.12.2.jar
scala-reflect-2.12.2-sources.jar
Ignoring IDEs or build tools, I am curious as to whether all of these jars are actually required for running code that includes portions written in the Scala language.
I assume that, if I don't use any of the Scala libraries contained in these jars, compiled Scala code can actually run without them (I'm not claiming that it's a good idea - just curious).
So, my question is, which jars are required for what functionality and whether I should ALWAYS include all four jars in any application that uses Scala code.
To clarify, my question is only related to running the code, not building it.
Upvotes: 0
Views: 628
Reputation: 3814
The scala-library-2.12.2.jar is always "required". The Scala scala-reflect-2.12.2.jar is only required for projects that utilize reflection. The other two are exactly the same but with the source code also included in the package, those are never required to run the code.
A bit of clarification, technically the answer is none of those jars are required to run the code. This is because you do not technically need your dependencies to be packaged in jars inside your jar. Instead you can just choose to export the necessary class files with your project. However I think that's somewhat pedantic and a bit beyond what you're asking.
Also, be careful with the term "required" because often certain jar files are required to be repackaged as part of a licensing or redistribution agreement. This is not a technical requirement but rather a legal one.
Upvotes: 2