|JAVA_TOOL_OPTIONS||-Dfile.encoding=UTF8||This is necessary, if the source files are UTF8 encoded.
Annoying side effect: Compilation of a Java file produces the (harmless)
warning Picked up JAVA_TOOL_OPTIONS. Alternatively specify
The Ruby files don't need to be compiled, but a syntax check can be done by, i.e.
jruby -c rbsrc\asahi.rb
The Java files are compiled with
javac -d . jsrc\HE.java
This will generate the following class files:
.\Jmain.class .\vp\VP.class .\hostenv\HE.class
Create a file ./MANIFEST.MF - actually, any name is fine, but this name is commonly used - with the following content:
Manifest-Version: 1.0 Main-Class: Jmain
mkdir .\jars\vp.jar jar cvfm .\jars\vp.jar .\MANIFEST.MF -C . .\Jmain.class .\vp\VP.class .\hostenv\HE.class .\rbsrc
This creates a file
jars\vp.jar. Note that by virtue of the last argument, the complete JRuby source dir is
included in the vp.jar.
The example program can be run by executing (i.e.):
java -cp c:\dl\jruby-complete-1.7.23.jar;jars\vp.jar Jmain
Note that we have explicitly name the start class, Jmain, even
though we have put it into the mainifest: Since we have two jar files, there
are two manifests, and it would not be clear, which of those would be the one
which names the start class. Also,
-cp option is used.
Since the jar command doesn't offer an easy way to merge two jar-files into one, you have to unpack them, merge the manifests, and pack everything together. Especially merging the manifests can, in theory, be tedious, but at least with the current JRuby versions, I found this unnecessary. Here is how to proceed:
mkdir jctemp cd jctemp jar -xf c:\dl\jruby-complete-1.7.23.jar jar -xf ..\jars\vp.jar cd .. jar -cvfm .\jars\combined.jar .\jctemp\META-INF\MANIFEST.MF -C .\jctemp . >NUL
The redirection to the bit bucket in the combine-step is strongly recommended, otherwise you will be overwhelmed by the amount of what will be written to standard output (jruby-complete-xxx.jar contains many, really many elements).
To run the example, execute:
java -jar .\jars\combined.jar
Note that it is not necessary here to specify the start class. Since we
have only one jar file, the start class is derived from the manifest. In this
-jar option is used.