By Kevin Yank

Write Java Web Apps in Visual Basic (or JavaScript!)

By Kevin Yank

More from the JavaOne 2006 keynotes

One of the new key features in Java 6 (Mustang), available now in beta and weekly snapshots and slated for release in October, is support for alternative languages running on the JVM. In particular, Java 6 will ship with support for running JavaScript code as a first-class citizen, with complete access to the Java class libraries and the ability to call back and forth between Java and JavaScript code within a single application.

At JavaOne on Tuesday, Sun took the wraps off of two new projects that are taking advantage of this capability in a way that will be of interest to web developers. The first, Project Semplice, brings the Visual Basic language to the Java platform. Not meant for porting existing VB apps over to Java, but rather for allowing Visual Basic developers to transition to the Java platform while leveraging their existing skills, Semplice lets you write code using VB syntax (including all the automatic type conversion, support for properties implemented by methods, and other niceties that VB developers love so much) that compiles to Java classes that will run on the Java 6 VM. As J# is to Java, Semplice is to Visual Basic.


In the demo during the keynote, Semplice developer Tor Norbye (regular on the Java Posse podcast) demonstrated building a simple web application in VB using a pre-release version Java Studio Creator. Starting from a blank page, he dragged a number of JavaServer Faces (JSF) components onto the page, then double-clicked one to add an event handler to it. The editor that popped open contained a new event handler written in Visual Basic, to which he quickly added some simple implementation code, then compiled and ran the application.

The application, he pointed out, made use of JSF components written in Java, and he accessed properties of these directly from his Visual Basic code. Additionally, the JSF components call the Visual Basic event handling code from within Java. Semplice allows these two languages to work together transparently.

Thanks to features of the VB language, instead of having to call farenheit.getText() to obtain the value of the farenheit form field, he could refer to it as farenheit.Text, or even just as farenheit, thanks to Visual Basic’s flexibility. He was also able to use the resulting String value in an arithmetic calculation (i.e. celsius = (farenheit - 32) * 5 / 9) without having to convert it to an integer.

For developers that want the power of Java when writing server-side business logic, but want a more flexible and loosely-typed language when writing web presentation logic, Visual Basic running on the Java VM could well be a very attractive option!

Even more flexible than Visual Basic, however, and likely much more familiar to them as well is JavaScript. So why not write the server-side code of web applications in JavaScript? That’s exactly what Project Phobos will do. With Project Phobos, you can either write server-side application logic with JavaScript directly within your HTML templates (much like you can in PHP or JSP), or in separate “helper” scripts to keep your code separate from your markup.

Along with the many other projects working to bring other languages to the Java VM, these two projects give developers even more choices when considering Java as a web development platform.

The video of both demos may be found in Segment Three of the Sun Technical General Session: Java Platform Roadmaps: The Big Stuff, Today & Tomorrow from Day 1 of the JavaOne 2006 conference.

Full details and screenshots of Semplice in action on project developer “HerbertC”‘s blog.

The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account