- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
How do I make an executable program?
Created by admin on 2008-07-28.
Updated: 2008-07-28, 16:26
There are two general strategies: you can write a script file and use the interpreter, or you can compile an object that has a main method.
To make a script file, simply put Scala code into a file and make the file executable. See the scala(1) reference page for details and examples.
To use a main method, you must include in your Scala code an object with a main method. The main method should have the same type signature as in Java, namely:
def main(args: Array[String]): Unit
Once you have such an object, you can already run it using the scala(1) program. To make your program more convenient, you can write a shell script file that invokes scala
the correct way, thus making your program appear like any other program on the platform.