I have two files:
logic.scala and main.scala
logic.scala contains one class and main.scala have one class with method main (to run it). And I want to import a class from logic.scala and use this class to create object(s) and work with them.
How to import and compile it in proper way?
package logic
class Logic{
def hello = "hello"
}
package runtime
import logic.Logic // import
object Main extends Application{
println(new Logic hello) // instantiation and invocation
}
- compile the files with
scalac
scalac *.scala
- run your application with
scala
scala -cp . runtime.Main