I used scala-compiler.jar to compile an embedded Scala program This scala program imports a class written using jni
- The code is as follows
class test{
def test(ctx: ContractContext): ActionResult = {
val s = new DllTest
s.loadLibrary()
print(s.intMethod(5))
null
}
}
DllTest is a jni application
- The error is as follows
error: error while loading Object, Missing dependency 'object scala.native in compiler mirror', required by /modules/java.base/java/lang/Object.class
Failed to initialize compiler: object scala in compiler mirror not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programmatically, settings.usejavacp.value = true.
Anyone knows the reason? And how to solve the problem?
It works fine in the main function
def main(args: Array[String]): Unit = {
//Create system instance
val s = new DllTest
s.loadLibrary()
print(s.intMethod(5))
......
According to
object scala in compiler mirror not found - running Scala compiler programmatically
"scala.runtime in compiler mirror not found" but working when started with -Xbootclasspath/p:scala-library.jar
Why am I getting "object scala.runtime in compiler mirror not found." with scala-maven-plugin when dependency is upgraded?
object scala in compiler mirror not found - running Scala compiler programatically [no sbt - no IDE]
most probably you should try to switch on
settings.usejavacp.value = trueas written in the error message. How to feed this setting to the compiler depends on how you run it.See examples how to run the compiler programmatically in
Exception while compiling scala code from Java program
How to compile and execute scala code at run-time in Scala3?
How can I run generated code during script runtime?
Scala reflection: compile akka actor with protobuf
Dynamic compilation of multiple Scala classes at runtime
How to eval code that uses InterfaceStability annotation (that fails with "illegal cyclic reference involving class InterfaceStability")?
Tensorflow in Scala reflection
dynamically parse json in flink map