Domenico
Domenico

Reputation: 51

run compiled Scala Files on Java Virtual Machine

Is it possible to run scala files with Java Virtual Machine? I am trying a lot but nothing works. Can someone give me some help with command line? Thanks a lot!

Upvotes: 5

Views: 4905

Answers (2)

Daniel C. Sobral
Daniel C. Sobral

Reputation: 297275

Well, it depends on whether you are generating a JAR or class files, etc, but it is pretty simple: you run it like any Java program, but including the Scala library as a dependency.

java -cp .:/path/to/scala-library.jar MyApp

Upvotes: 8

Luigi Plinge
Luigi Plinge

Reputation: 51109

Scala runs on the JVM. It does not have a separate virtual machine. But it does have its own libraries, so you will need to have Scala installed wherever you're running it.

If it's compiled you will have a .class file, so you just type in

scala -cp myClassPath myPackage.myFileName

as you would with Java. You don't need the -cp option if you've navigated to your classes folder.

It is possible to run Scala classes using the java command - you can probably Google how to do it, but you would need to sort out all the correct imports and there's no reason not to just use scala as above.

Upvotes: 4

Related Questions