-
https://news.ycombinator.com/item?id=42487929 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Initial attempt to run JRuby scripts using Jbang. $ jbang run jruby_cli.java my_script.rb 1 2 3
Hello from JRuby!
Arguments received:
Arg 0: 1
Arg 1: 2
Arg 2: 3 jruby_cli.java ///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.jruby:jruby-complete:9.4.13.0
import org.jruby.Main;
public class jruby_cli {
public static void main(String[] javaArgs) {
Main.main(javaArgs);
}
} my_script.rb # my_script.rb
puts "Hello from JRuby!"
puts "Arguments received:"
ARGV.each_with_index do |arg, index|
puts " Arg #{index}: #{arg}"
end
if ARGV.empty?
puts "No arguments provided to the Ruby script."
end |
Beta Was this translation helpful? Give feedback.
-
Nice. Btw, personally I would be much more inclined to try to add proper JRuby support to JBang (following the pattern of Jshell) than when we were talking about Python support. Mainly because the way to support JRuby seems obvious, there's one "official" way and if we do it that way we know we can support all JRuby scripts. |
Beta Was this translation helpful? Give feedback.
-
JRuby already has a jbang-catalog repo:
Maven Jar dependencies are also supported: There does not seem to be any benefit to further integrate JRuby and JBang. |
Beta Was this translation helpful? Give feedback.
JRuby already has a jbang-catalog repo:
$ jbang run@jruby --version
Maven Jar dependencies are also supported:
There does not seem to be any benefit to further integrate JRuby and JBang.