Native JRuby Launcher For Windows
I’ve been fixing some JRuby BAT launcher script errors recently, and it was tricky, as always: as soon as you fix one issue with the way the BAT file parses parameters, a new one pops up (and a couple of regressions on top of that). Spaces, brackets, quotes, & and ^ signs, you name it. We’ve been playing this game for years now, and every time it just gets uglier and uglier. So, this time I broke down and started to look for better alternatives to the BAT launcher files. And it turned out that there is, like, a hidden industry of Java launchers out there, with at least 4 different open-source projects, not to mention the commercial offerings.
So I tried Launch4J, WinRun4J, Groovy Launcher, Eclipse and Netbeans launchers. For more details, take a look at JRUBY-4100. And the winner was … Netbeans! The NetBeans guys have nice, clean, simple C++ based launcher, (re)written not that long ago. It was easy to start hacking on, right in Netbeans itself. And I can say, Netbeans C/C++ support is really good now, all the more reasons to use it! At any rate, writing C++ code was much, much better than struggling with batch files.
So I tweaked and cleaned and adjusted the Netbeans launcher to make it suitable for JRuby. And here it is, the JRuby native launcher for Windows. It has nice Java detection, an ability to launch Java in-process (so in the Task Manager one can see jruby.exe process, not just java.exe), it handles most of JRuby command line arguments already, it allows to pass parameters to the JVM when needed (via –J switch, like we always did), and it can handle spaces and brackets in the path, etc. There is a nice feature to enable tracing to see what’s going on (via –-trace command line option). This is an early version though and it will be improved further to provide the very same functionality JRuby users expect (additional command line switches like –client and –-server, etc). Once all the functionality is there, the plan is to integrate it into the main JRuby repository. But if you wish to try it now, you could either build it from sources or go to the GitHub link above and grab the version from the “Downloads” section. And the comments/suggestions and bug fixes are always welcome!
October 17th, 2009 at 8:51 pm
We’ll need to see how this works with Nailgun, since there are many Windows users using Nailgun, and it only gets launched properly from the bat scripts. Maybe that logic can be ported in, even if it just execs ng.exe as a child process?
October 20th, 2009 at 8:53 pm
Nick Sieger has tweaked the launcher so that it can now handle Nailgan with on problems, sweet.
November 11th, 2009 at 10:02 pm
Hi,
Nice post + job on the native launcher!
At my company we are also using/maintaining a native (Windows) launcher (and a [ba]sh-based counter part for linux/unix-es) and I’ve always asked myself if a pure Win Batch script would suffice; I would have imagined something like Ant’s, Tomcat’s or Groovy’s launchers.
However, given the many gotchas of Win Batch that you’ve already enumerated and the flexibility and power of C + native/system API, now I also think that this is by far a better approach. Your post offered me the external validation I was looking for
and now I am pretty sure we are doing the right thing.
Good luck and looking forward to see how this goes! (pretty well how I see it)
Regards, Tavi