Do you know why “sbt run” can success, but running “scala program.scala” directly got the error following?
$ scala target/scala-2.13/hivedb_2.13-0.1.jar
at java.base/java.lang.Class.forName0(Native Method)
sbt run can be fine:
$ sbt run
[success] Total time: 2 s, completed Mar 1, 2022, 11:30:43 AM
This is a simple Hive client using the only package:
libraryDependencies += "org.apache.hive" % "hive-jdbc" % "2.3.9"
You would need to run
scala with a
-classpath argument with the paths of all the dependency JARs, including any transitive dependencies.
export dependencyClasspath will show you what that looks like. (Note that the output will include Scala library JARs which you don’t need to include when running the code with the
scala command, but do need to include if you’re running it with the
may I ask for the complicated java dependencies how do you deploy your program?
It has no possible to ask every server box to install sbt and run scala program via sbt run.
As I mentioned here there are a couple of options, it depends on your use case to determine which is the best one.
Yes, but the target machine needs a JDK and Scala or maybe Ammonite.
What kind of issues?
If missing dependencies, you need to provide them somehow.
Or if rather you have mismatches of versions then you need to review what are the duplicated entries in the class path.
No idea what Resin is, but yes you can create containers like Docker; that is probably what most of us do.
And for that you have a couple of options:
- Using sbt-assembly + a custom
docker build after a
- Using sbt-native-packager + its Docker plugin.
You may also explore using Graal to create native images. This is great for small scripts / programs and CLI tools.