“scala.runtime in compiler mirror not found” but working when started with -Xbootclasspath/p:scala-library.jar

江枫思渺然 提交于 2019-11-29 03:45:26

The easy way to configure the settings with familiar keystrokes:

  import scala.tools.nsc.Global
  import scala.tools.nsc.Settings
  def main(args: Array[String]) {
    val s = new Settings
    s processArgumentString "-usejavacp"
    val g = new Global(s)
    val r = new g.Run
  }

That works for your scenario.

Even easier:

java -Dscala.usejavacp=true -jar ./scall.jar

Bonus info, I happened to come across the enabling commit message:

Went ahead and implemented classpaths as described in email to scala-internals on the theory that at this point I must know what I'm doing.

** PUBLIC SERVICE ANNOUNCEMENT **

If your code of whatever kind stopped working with this commit (most likely the error is something like "object scala not found") you can get it working again with either of:

passing -usejavacp on the command line

set system property "scala.usejavacp" to "true"

Either of these will alert scala that you want the java application classpath to be utilized by scala as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!