'. '


From APIDesign

Jump to: navigation, search

AvatarJS is a re-implementation of NodeJS on top of the JVM. JDK8 comes with Nashorn and that is certainly better JavaScript virtual machine than old Rhino. However NodeJS is not just JavaScript, it also contains a lot of native bindings. What can be done with those?


Get AvatarJS

Well, just download AvatarJS binaries and you are set to go. One could get the AvatarJS libraries from maven.java.net (as of Feb 17, 2014):

To bind them together I renamed the libraries:

libavatar-js.so -> libavatar-js-linux-x64.so
# and then I could execute them as 
java -Djava.library.path=. -jar avatar-js.jar


Compatibility was tested on http://www.manning-source.com/books/cantelon/code_Node.js.zip sources. As of Mar 18, 2014 the 2/chat/ example works.

The 8 example is using const keyword in mongodb NodeJS modules (reported and fixed as https://bugs.openjdk.java.net/browse/JDK-8027933 on May 2nd, 2014). One can either replace the const with var or get latest Nashorn build.

Then the application starts, but crashes. The single line fix is documented on the AvatarJS main page: inserting "if (options.locals)" was enough to fix the problem. Then the application started.


The NetBeans tooling (including excellent debugging, see Nashorn) is being developed at http://hg.netbeans.org/core-main/file/32b5ebff07b4/avatar_js.project

I know that Tim Boudreau has module with good NodeJS support as well and I let him put here a link once he also supports AvatarJS.


Yeah, so far V8 is faster than Nashorn, but let me point you to presentation about next generation Nashorn virtual machine to see where the speed will come from...

Personal tools