I cd
'd into a directory containing two Scala classes.
C:\Kevin\Workspace\>dir
09/08/2013 09:13 PM 331 Max.scala
09/08/2013 09:13 PM 459 Test.scala
2 File(s) 790 bytes
2 Dir(s) 72,008,863,744 bytes free
Then, I opened up REPL:
C:\Kevin\Workspace\>scala
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import java.lang.Runtime
import java.lang.Runtime
scala> val runtime = Runtime.getRuntime
runtime: Runtime = java.lang.Runtime@55dae09c
Then (with this post's help) I tried to compile my *.scala files via scalac
as an argument to Runtime#exec
, but it failed.
scala> runtime.exec("scalac Max.scala Test.scala")
java.io.IOException: Cannot run program "scalac": CreateProcess error=2, The system cannot find the file specifie
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at .<init>(<console>:12)
at .<clinit>(<console>)
How can I do the above in Scala?