Run node-js from Java or Groovy


Question

anyone experimented on how to run node.js module or a script from java or groovy?

Could groovy command.execute() do it? If so then would it behave the same across different op sys.

Worth noting is that ideally, I would like that node.js would not be depended upon installation in the system and node command, but but packaged via ./configure and make, so that it could be used as a library..

Thanks

Edit: Basically I want this so that I could use node.js module, a client side framework(coffee-script, jade,stylus etc. And this is bundeled in Brunch), as a Grails plugin. So that the plugin is self-contained with no system dependency.

1
8
2/4/2012 9:32:34 AM

You might find what you're looking for in vert.x.

From the site:

What is vert.x?

The next generation polyglot asynchronous application framework. (Formerly known as node.x)

  • Runs on the JVM.
  • Embraces the good bits of event driven frameworks like node.js then adds some even juicier bits.
  • Everything is non-blocking.
  • Polyglot. vert.x will be usable from multiple languages: Ruby, Groovy, Java, JavaScript, Python, Clojure, Scala. Currently we support Java and Ruby and have partial Groovy support. Write your code in the language you choose. Leverage the power of vert.x from that language.
  • Goes with the recent developments with InvokeDynamic in Java 7 and bets on the JVM being the future premier runtime for dynamic languages.
  • Enables you to create network servers or clients incredibly easily.
  • True scalability. Unlike other well-known event-driven frameworks, you can have more than one event loop per process. No more spinning up 32 instances just to utilise the cores on your server.
  • Incredibly simple concurrency model. Write your code as single threaded but watch it scale across multiple cores. No need to worry about race conditions or locks.
  • Understands multiple network protocols out of the box including: TCP, SSL, HTTP, HTTPS, Websockets.
  • Efficiently serve static files from the filesystem bypassing user-space altogether.
  • Simple Sinatra/Express style resource based web routing.
  • Distributed event bus. Multiple vert.x instances work together seamlessly to provide a distributed event bus
  • SockJS support
9
2/14/2014 10:24:48 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon