tags:

views:

133

answers:

1

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 wannt to import 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?

+8  A: 
  • logic.scala code
package logic

class Logic{

  def hello = "hello"

}
  • main.scala code
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
Vasil Remeniuk