0

I already have a program that uses JavaCompiler api for compiling Java code at runtime. Can I use the same compiler for scala code? If not, what is the best way to compile scala code in a Java program?

Thanks

1 Answers1

1

See the following answer, and in it, also the answer linked by @mastov. You may, however, be able to use the new process handling capabilities in Java 9 instead of ProcessBuilder.

Compile Scala code to .class file, in Java

On Java 9 Process API:

https://www.javaworld.com/article/3176874/java-language/java-9s-other-new-enhancements-part-3.html

Ben Weaver
  • 960
  • 1
  • 8
  • 18
  • I tried the method in the link provided, and I am running into this error: Exception in thread "main" java.lang.NoSuchMethodError: scala.tools.nsc.Global$gen$.mkBlock(Lscala/collection/immutable/List;)Lscala/reflect/internal/Trees$Tree; Any leads on this? – user9024779 Aug 03 '18 at 10:06