I decided to make a script that would take a jar filename as an
argument and then run the jar by finding out its main class and
executing its static main(args) method. To load the main class I use a
JRuby class derived from Java’s ClassLoader but without adding
anything to it. This seems to work to load the class, but I can’t seem
to call main(args) on it. I’ve done some googling and it’s starting to
look like it’s not possible to invoke a static Java method on
something unless you actually hard-code its class name. Is this
correct? And if so, are there any plans to “fix” this?
Also, as an aside, I wonder if it’s possible for a JRuby script to
modify the classpath seen by the class loader. That’s my other
obstacle.
On Fri, 2011-05-13 at 09:56 -0500, Eric C. wrote:
I decided to make a script that would take a jar filename as an
argument and then run the jar by finding out its main class and
executing its static main(args) method. To load the main class I use a
JRuby class derived from Java’s ClassLoader but without adding
anything to it. This seems to work to load the class, but I can’t seem
to call main(args) on it. I’ve done some googling and it’s starting to
look like it’s not possible to invoke a static Java method on
something unless you actually hard-code its class name. Is this
correct? And if so, are there any plans to “fix” this?
That doesn’t sound right. Bring up a jruby console (i did it on 1.6,
not sure if that makes a difference) and try this:
include Java
javaClass = eval (“JavaLang::Integer”)
javaClass.parseInt(“12”)
parseInt is a static method declared on java.lang.Integer - Nothing hard
coded about that.
Also, as an aside, I wonder if it’s possible for a JRuby script to
modify the classpath seen by the class loader. That’s my other
obstacle.
Which class loader? This is probably more a question for a java mailing
list, because if it is exposed in Java, you can call it from jruby.
IIRC.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
–
Nick G.
Developer @ Media Service Provider
+44 207 729 4797