Scala, ZXTM and Java Extensions
Scala is a neat hybrid language which is both object oriented and functional. Its best aspect is that you can utilize all of the standard Java libraries without writing any Java code. Check out http://www.scala-lang.org/ for more information on the language itself, as I'm just going to talk about how to get a simple 'Hello World' example working with ZXTM. Why is it possible for us to use Scala in place of Java with ZXTM? Well, since Scala targets the JVM we can just import the compiled class files into ZXTM and they are recognized in the same way as any Java class file. The only extra step we need to take is to import the Scala libraries into ZXTM, so that they are available to the same Java runtime. This additional file, If you want more information on Java Extensions in ZXTM, then have a look at the related articles Introducing Java Extensions and "Hello, World!" Java Extension. Ok, let's look at a simple hello world example in Scala.
Quite simple and no magic, we just extend an HttpServlet as we would using Java and act on the Response object providing some content. Put this in a file
This will produce a class file, Now you are all set to work with Scala in ZXTM! UPDATE: Incorporated changes suggested by James Iry. Comments:This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Comment from:
James Iry [Visitor]
Since the servlet container is responsible for managing the lifecycle of servlets, the use of "object" doesn't really make sense here. In Scala an "object" declared at top level is a singleton. The use of an object is also why you got two class files. One holds the definition of the class to which the singleton belongs and the other holds the (lazily instantiated) static reference.
If you rewrote your code as "class MyServlet extends HttpServlet..." you'd only get one class file, MyServlet.class, and the solution would be that much more indistinguishable from Java. PS: for some reason this blog is rejecting a perfectly valid url for my site "http://james-iry.blogspot.com/"
Comment from:
Owen Garrett [Zeus Dev Team]
James - the blog subscribes to a central blacklist of words and URLs, and for some reason, *.blogspot.com was in the list.
I've whitelisted it locally... for everyone else's benefit, James' site is http://james-iry.blogspot.com |
Recently...
Other Resources
|

There has been a lot of talk over the past few years about new and different languages targeting the JVM as their runtime platform. Scala has been one of the most high-profile languages in the JVM vanguard. Most notably, in the past year Twitter has announced that it is migrating away from Ruby on Rails to Scala because of RoR's lack of scalability.




