Monday, April 28th, 2008

Java in JavaScript

Category: Games, Java, JavaScript

As John Resig reports, the Japanese Shibuja.JS user group managed to port (at least in parts) the Java Virtual Machine over to JavaScript. The project is called Orto and there is a Japanese PDF explaining the details (I guess) available on John’s site.

Using this you can convert Java code into bytecode and embed it in the document.


  1. "java/lang/Thread 1316742099":function(){var orto333=orto245[0];
  2. var orto336=orto350(orto333);
  3. if(orto336.orto340!=orto310){orto223("java/lang/IllegalThreadStateException",null);
  4. return ;
  5. }

One of the examples shown is a pretty cool Tetris game:

Screenshot of Xetris - a Java Tetris in JavaScript

As Orto simulates the multithreaded nature of Java with yields and timeouts this is of course hard-core simulation (read: hack), but the benefit are that you could Java Games on non-JS devices, like the iPhone.

Orto also seems to try to simulate the Java UI conventions, thus making it easy to convert existing applications (to a certain degree as there is no equivalent in HTML for the richness of Java UIs unless you build them yourself as libraries ike Dojo or Quoxdoo did).

More details are available on John Resig’s Blog

Posted by Chris Heilmann at 1:26 am

3.9 rating from 16 votes


Comments feed TrackBack URI

Actially, I saw Orto in 2005. It seems to be released in 2004 or even earlier, which means ealier than the word Ajax. Quite impressive.

Comment by akky — April 28, 2008

Maybe I’m wrong here (and bit offtopic too), but Resig had a nice article about timeouts and intervals and I don’t think it can be used for “simulating” multithreading. But that’s my two cents, and of course it’s good to see this new renessaince of the Javascript we have nowdays.

Comment by deadcabbit — April 28, 2008

isn’t this what the Google Web Toolkit does?

Comment by naikrovek — April 28, 2008

@naikrovek: This seems to be a JVM implementation, not a Java to JavaScript translation

Comment by andytesti — April 28, 2008

Ok, but why? IMO, the only strength of Java is the multitudes of libraries available for it.

Comment by tlrobinson — April 28, 2008

Leave a comment

You must be logged in to post a comment.