Re: [nodejs] Running NodeJs inside JVM

885 views
Skip to first unread message

Forrest L Norvell

unread,
Dec 7, 2012, 4:57:22 PM12/7/12
to nod...@googlegroups.com
On Fri, Dec 7, 2012 at 11:03 AM, prashant pandey <prashan...@gmail.com> wrote:
I want to know has anyone tried to run NodeJs inside JVM? Or is there any specific approach we need to employ to get this done?

Since Node is only partly the JavaScript code of the standard library and predominantly the compiled native code of V8 and libuv, embedding Node in a JVM is likely to be quite a challenge. Is there a reason you can't just use straight Node, or alternately can't use something like Ringo with Nitro?

F

Ilya Dmitrichenko

unread,
Dec 7, 2012, 5:03:57 PM12/7/12
to nod...@googlegroups.com
Yeah, you should also checkout vert.x (http://vertx.io/)



F

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Rick Waldron

unread,
Dec 7, 2012, 7:14:23 PM12/7/12
to nod...@googlegroups.com

Alan Gutierrez

unread,
Dec 8, 2012, 4:01:30 PM12/8/12
to nod...@googlegroups.com
Excellent guidance from everyone. I wanted to add...

Just run node as a child process of your JVM application. The node
executable is small and easy to redistribute. Node now runs in as many
places as the JVM. I find that the promise of write once, run everywhere
is easier to realize with Node.js than with Java.

--
Alan Gutierrez - @bigeasy

On 12/7/12 7:14 PM, Rick Waldron wrote:
> I believe Nashorn purports to be a Node compatible JS engine on the JVM
>
> https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=6661&tclass=popup
> http://www.theregister.co.uk/2012/11/27/project_nashorn_server_javascript/
> http://www.oracle.com/javaone/lad-en/session-presentations/clientside/24821-enok-1439095.pdf
> (in case it's not obvious, this one is a pdf)
>
> Rick
>
>
>
>
> On Fri, Dec 7, 2012 at 5:03 PM, Ilya Dmitrichenko
> <errorde...@gmail.com <mailto:errorde...@gmail.com>> wrote:
>
> Yeah, you should also checkout vert.x (http://vertx.io/)
>
>
> On 7 December 2012 21:57, Forrest L Norvell <for...@newrelic.com
> <mailto:for...@newrelic.com>> wrote:
>
> On Fri, Dec 7, 2012 at 11:03 AM, prashant pandey
> <prashan...@gmail.com <mailto:prashan...@gmail.com>>

Evangelos Pappas

unread,
Dec 9, 2012, 3:02:12 PM12/9/12
to nod...@googlegroups.com
If you just want to start nodeJS from your JVM runtime then just use the ProcessBuilder, It'll start your NodeJS with any arguments & environment settings you wish and it'll gain a Child PID but without using any JVM resources during it's(generated NodeJS process) runtime.

Cheers!

On Friday, 7 December 2012 21:03:51 UTC+2, prashant pandey wrote:
Hi All,

Simon

unread,
Dec 9, 2012, 10:57:20 PM12/9/12
to nod...@googlegroups.com
In response to Why use Nashorn instead of Node, I thought it was funny that one commenter mentioned:
"Node.js uses Google's V8 Javascript engine which is too fast for some applications. Also, it doesn't use enough memory, a problem the JVM is likely to correct..."

Simon

unread,
Dec 10, 2012, 12:02:57 AM12/10/12
to nod...@googlegroups.com
Oh, there's also DynJS which Douglas Campos presented at JSConf.eu 2011 and looks very promising. It seems pretty active on GitHub and I believe it's almost completely passing Ecma tests.


On Friday, December 7, 2012 7:03:51 PM UTC, prashant pandey wrote:
Hi All,

prashant pandey

unread,
Dec 10, 2012, 1:36:27 PM12/10/12
to nod...@googlegroups.com
Hi Alan,

thanks for your time. 
Let me tell bit more about the use-case. I want to run the nodeJs program inside OSGi (equinox). For that matter I would need a plugin bundle of NodeJs library to be loaded inside OSGi. Is there a way to that?

Thanks,
Prashant

Mark Hahn

unread,
Dec 10, 2012, 1:39:05 PM12/10/12
to nodejs
Lua is the king of embedded languages. Give it a try.

prashant pandey

unread,
Dec 10, 2012, 1:48:52 PM12/10/12
to nod...@googlegroups.com
What's Lua?

Mark Hahn

unread,
Dec 10, 2012, 2:11:22 PM12/10/12
to nodejs
A programming language similar to JS. Google it. Home page is here:
http://www.lua.org/ List of tutorials is here:
http://lua-users.org/wiki/TutorialDirectory A framework that
duplicates node in lua is here: https://github.com/ignacio/luanode

It was designed for embedding. The interpreter is actually just a
shell that embeds it. It is highly regarded.


On Mon, Dec 10, 2012 at 10:48 AM, prashant pandey
<prashan...@gmail.com> wrote:
> Lua

Evangelos Pappas

unread,
Dec 10, 2012, 2:11:43 PM12/10/12
to nod...@googlegroups.com
IMHO, your architectural design should be revisited. the short answer is that Yes you can do it and I'll explain how. The long answer is that OSGi is  a system that treats its parts as a module and communicate with them through native busses, so it may wrap them and handle any state of their runtime. NodeJS in either way, it has its own Runtime environment and more important it's a different platform. So OSGi can operate with a different platforms and more especially if not OSGi modules are not wrapped by the same OSGi.

The solution to your case it's simple, as you may start your nodeJS with the process builder ( I've describe it in my previous post ), and build an OSGi module tha communicate with node though a message broker. From my experience I'd suggest you to use ActiveMQ as a broker and Apache-Camel to your OSGi module. NodeJS can implement the Stomp protocol which is supported by activeMQ and is simple enough to start your production soon enough.

Without the OSGi implementation I have test a NodeJS<->ActiveMQ<->Apache Camel communication and reached 6k TPS.


Cheers!

Reply all
Reply to author
Forward
0 new messages