How do I determine the jvm arguments to run a scala programs?

133 views Asked by At

TL;DR: What's the kosher way of launching Scala programs through JDI?

I want to use JDI to implement a debugger-of-sorts for Scala. In particular I want use a LaunchingConnector. And ideally I want the user to specify whether I should launch Scala 2.11 or 2.12.

I have Scala 2.11 installed on my system, and by running a Scala shell and looking in my process table I can establish that the following JVM command line options are sufficient to get the job done:

environment.get("options").setValue("-Xmx256M -Xms32M -classpath /usr/share/scala-2.11/lib/hawtjni-runtime.jar:/usr/share/scala-2.11/lib/jansi.jar:/usr/share/scala-2.11/lib/jline.jar:/usr/share/scala-2.11/lib/scala-actors.jar:/usr/share/scala-2.11/lib/scala-compiler.jar:/usr/share/scala-2.11/lib/scala-library.jar:/usr/share/scala-2.11/lib/scala-parser-combinators.jar:/usr/share/scala-2.11/lib/scala-reflect.jar:/usr/share/scala-2.11/lib/scala-xml.jar:/usr/share/scala-2.11/lib/scalap.jar:scalacheck_2.11-1.14.1.jar:target/scala-2.11/classes/ -Dscala.home=/usr/share/scala-2.11 -Dscala.usejavacp=true -Denv.emacs=")

For context, this is combined with environment.get("main").setValue("scala.tools.nsc.MainGenericRunner <my program> <arguments to my program>") where (effectively but not literally) val environment = com.sun.jdi.Bootstrap.virtualMachineManager().defaultConnector().defaultArguments().

Are all of the above necessary?

Is there some way I can launch a working Scala process using the JDI framework without hardcoding the above paths? Is there a way I can find out what paths to use for Scala 2.12?

Note that my classpath also includes a scalacheck jar file, which I manually downloaded. Can I programatically determine where sbt downloads library files to? Can I compute that part of the classpath too?

0

There are 0 answers