;

Running Node.js applications on the JVM with Nashorn and Java 8

admin 06:37:am Feb 26 2018

The following steps show how to run a simple Node.js web application on OSX. The steps should be very similar for Linux or Windows.

Download avatar-js.jar from the java.net Maven Repo. You can find the current version here

Example file: avatar-js-0.10.25-20140313.063039-43.jar

Download the native library avatar-js.dylib from the java.net Maven Repo.

Current version is here

Example file: libavatar-js-macosx-x64-0.10.25-20140312.062209-35.dylib

For Linux you would download the corresponding .so file from ../libavatar-js-linux-x64/0.10.25-SNAPSHOT/

For Windows you would download the corresponding .dll file from ../libavatar-js-win-x64/0.10.25-SNAPSHOT/

Rename the native library to avatar-js.dylib and rename the jar to avatar-js.jar and put both in a directory called dist

Place the below code in app.js file and place in your project folder


node.js application on the JVM platform

Run the command:

java -Djava.library.path=dist -jar dist/avatar-js.jar app.js

The output should be:

Server running at http://127.0.0.1:8000/

Related Post

Comments

No comments yet. Be the first!

Add Comment

Adding comments has been disabled.