Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Created October 21, 2010 12:13
Show Gist options
  • Select an option

  • Save bernerdschaefer/638382 to your computer and use it in GitHub Desktop.

Select an option

Save bernerdschaefer/638382 to your computer and use it in GitHub Desktop.
simple jruby wrapper script with jruby-jars
#!/usr/bin/env ruby
require 'rubygems'
require 'jruby-jars'
jruby = JRubyJars.core_jar_path
# => "gems/jruby-jars-1.5.3/lib/jruby-core-1.5.3.jar"
jruby_stdlib = JRubyJars.stdlib_jar_path
# => "gems/jruby-jars-1.5.3/lib/jruby-stdlib-1.5.3.jar"
classpath = [
JRubyJars.core_jar_path,
JRubyJars.stdlib_jar_path
].join(File::PATH_SEPARATOR)
# => "jruby-core-1.5.3.jar:jruby-stdlib-1.5.3.jar"
java_args = [ "-cp", classpath, "org.jruby.Main" ]
ruby_args = ARGV
exec("java", *(java_args + ruby_args))
# => java -cp jruby-core.jar:jruby-stdlib.jar
# org.jruby.Main -e 'puts 1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment