Codetown ::: a software developer's community
object Hello {
def main(args: Array[String]): Unit = {
println("Hello world.")
}
}
powerbookg4:tmp zemian$ scalac Hello.scala powerbookg4:tmp zemian$ scala Hello
Hello world.
Note that Scala main entry program is a "object" instead of "class". "object" in Scala is like a class that define a type, but it force it to be a singleton(only one instance), so it almost like "static" in Java. Your main entry in command line must be an object with the main method defined.
You may turn your source file into a script by enter a expression that invoke the main method on the end of the file, and then run it through "scala" instead of compiling it. For example:
object Hello {
def main(args: Array[String]): Unit = {
println("Hello world.")
}
}
Hello.main(args)
powerbookg4:tmp zemian$ scala Hello.scala Hello world.
Note the difference. 1 no compile. 2 you give scala the script file name, not the type name!
Happy programming!
Tags:
Codetown is a social network. It's got blogs, forums, groups, personal pages and more! You might think of Codetown as a funky camper van with lots of compartments for your stuff and a great multimedia system, too! Best of all, Codetown has room for all of your friends.
Created by Michael Levin Dec 18, 2008 at 6:56pm. Last updated by Michael Levin May 4, 2018.
Check out the Codetown Jobs group.

George Mao shares a deep dive into evolving a basic web application to a planet-scale, global architecture. He walks through 5 stages of maturity, focusing on adding enterprise-grade security, achieving global high availability and disaster recovery, optimizing content delivery costs with CDNs, and implementing globally consistent persistence using serverless technologies.
By George MaoThis eMag explores architecture through five distinct lenses: the socio-technical forces that invisibly shape our code, the paradox of infrastructure that succeeds by disappearing, the power of distributed intelligence over centralized control, the evolutionary advantage of iteration over revolution, and the pragmatic reality of designing for inevitable complexity.
By InfoQGabriele Columbro, managing director of the Linux Foundation Europe, discusses the differences in the open-source landscape between Europe, China and the US. Stressing that the open-source landscape is the last favorable ground for global innovation in the current geo-political landscape.
By Gabriele Columbro
BellSoft has launched Hardened Images for Java containers, claiming 95% fewer CVEs and 30% resource savings. Built on Alpaquita Linux, the 3-in-1 solution combines runtime optimisation, OS hardening, and CVE remediation. It offers a secure, flexible alternative to Chainguard and Distroless, available now in three tiers.
By Mark Silvester
This week's Java roundup for December 1st, 2025, features news highlighting: JDK 26 in Rampdown Phase One; the formation of the JDK 27 Expert Group; GA releases of TornadoVM 2.0 and Spring gRPC 1.0; a point release of GlassFish 7.1; the December 2025 edition of Open Liberty; the first beta release of JHipster 9.0 and the second release candidate of Hibernate Search 8.2.
By Michael Redlich
© 2025 Created by Michael Levin.
Powered by