The “Hello, world!” Program
As a first example, we use the standard “Hello, world!” program to demonstrate the use of the Scala tools without knowing too much about the language.
The structure of this program should be familiar to Java programmers: it consists of the method main which prints out a friendly greeting to the standard output.
Run it interactively!
The scala command starts an interactive shell where Scala expressions are interpreted interactively.
The shortcut :q stands for the internal shell command :quit used to exit the interpreter.
Compile it!
The scalac command compiles one (or more) Scala source file(s) and generates Java bytecode which can be executed on any standard JVM. The Scala compiler works similarly to javac, the Java compiler of the Java SDK.
Execute it!
The scala command executes the generated bytecode with the appropriate options:
Script it!
We may also run our example as a shell script or batch command (see the examples in the man pages of the scala command).
Note: We assume here that the file script.sh has execute permission and the search path for the scala command is specified in the PATH environment variable.
You can also download IDE :-
Scala IDE provides advanced editing and debugging support for the development of pure Scala and mixed Scala-Java applications.
Useful links:- http://www.scala-lang.org/
http://scala-ide.org/download/sdk.html
http://www.scala-sbt.org/
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
No Comments