Forked from cshupp1/gist:1303191f26d653f3a9040114eb2d3fdf
Created
September 21, 2019 07:42
-
-
Save claudiug/918e958ff41e304106831bdf378afa3e to your computer and use it in GitHub Desktop.
jruby script in a jar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#contents of sample.rb | |
cat sample.rb | |
require './before' | |
puts "Hello World!" | |
#contents of before.rb | |
cat before.rb | |
puts "Before..." | |
#running: | |
>jruby sample.rb | |
Before... | |
Hello World! | |
#now we compile only sample.rb | |
>jrubyc sample.rb | |
#an 'ls' now shows | |
>ls | |
before.rb sample.class sample.rb | |
#now we jar it up: | |
>jar cf app.jar sample.class before.rb | |
#an 'ls' shows: | |
>ls | |
app.jar before.rb sample.class sample.rb | |
#a jar tvf shows the contents of our jar | |
>jar tvf app.jar | |
0 Fri Sep 20 19:51:22 EDT 2019 META-INF/ | |
66 Fri Sep 20 19:51:22 EDT 2019 META-INF/MANIFEST.MF | |
1185 Fri Sep 20 19:50:06 EDT 2019 sample.class | |
17 Fri Sep 20 18:46:38 EDT 2019 before.rb | |
#we run it | |
>java -cp %JRUBY_JAR%;./app.jar sample | |
Before... | |
Hello World! | |
#btw (for me) | |
echo %JRUBY_JAR% | |
C:\languages\ruby\jruby-9.2.8.0\jruby-complete-9.2.8.0.jar | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment