Reputation: 1190
I have a file named Hello.scala
that contains this simple code:
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")
}
}
I compiled it using this command:
$ scalac Hello.scala
The result was two files named HelloWorld.class
and HelloWorld$.class
.
What is these files? How can I use these files?
Note: My problem is not duplicate files. I want to know what is this files and how can I execute them?
Thanks for answer
Upvotes: 0
Views: 110
Reputation: 10894
This files are normal Java Class / Bytecode Files.
You can run them with
scala HelloWorld
//Hello, world!
Normally you also could run them with
java HelloWorld$ // Because it is an object which gets the $ sign at the end
But this throws an error as there has to be some wiring done to handle the special case of Object.
Upvotes: 1