I need to compile my JRuby application into a standalone JAR file. How can I do this?
相关问题
- Using task scheduler for running java jar (from ba
- jruby on rails - error when star server (rails s)
- Open an HTML File Inside a .JAR File
- IntelliJ & JRuby: how to setup project?
- consuming gems from jruby-complete
相关文章
- How to get java main class from jar file
- running nokogiri in Jruby vs. just ruby
- How to extend DataMapper::Resource with custom met
- Convert bloc to lambda in JRuby
- Bundling JAR dependencies with executable JAR (Übe
- Intellij Javafx artifact - how do you make it?
- ruby on android : ruboto vs rhodes?
- Rails console issues using JRuby: no prompt charac
To just run a script:
The JRuby site has a runnable JAR file that you can get at the JRuby download page. You want the JRuby complete JAR file. You can then run your application by doing
I believe you can also build the same JAR file from source. In the downloaded source do
To embed a Ruby script completely into a JAR file: Embedding JRuby in Java is a good starting point. You will probably want to unjar the
jruby-complete.jar
file, add your Java main class that either has the a callout to a JRuby script or has the Ruby code embedded in it, replace the manifest's main class to point to your new entry point, and jar it back up.JRuby 1.6 improved this. There's now a section of the wiki - StandaloneJarsAndClasses - that talks about how to use jrubyc to generate .class files and standalone jars.
With the new compiler, you can build .class files like this example from the wiki:
And you can set the entrypoint for a jar to org.jruby.JarBootstrapMain and add a jar-bootstrap.rb file.
Check out rawr. It is a gem that packages your application in a JAR file.
If you want to compile for source code protection you must produce a
.class
file for each script in your project (as described here) and then replace the contents of the original script withfor each of the compiled scripts.
Warbler 1.3.0 or newer can also be used to make an executable JAR file.
Quick instructions. Make sure you're using JRuby`s gem, etc. here:
You should now have a
myapp.jar
file in the current directory. According to theREADME
you just add any libraries you need in thelib
directory and use either (or both) a.gemspec
orGemfile
to control any other gems that need to be put into the.jar
file.