Rawr: how to run jruby-complete.jar with 1.9 mode?

Hi all,

I’m using jruby 1.6.7, rawr 1.6.3 and JDK 7 on my Windows 7 pc.

I tried the following:

C:\tmp\hello>ls
main.rb

C:\tmp\hello>cat main.rb
h = {:a => 1, :b => 2}
p h

C:\tmp\hello>jruby --1.9 -S rawr install
(omit output messages)

Edit line 65 in build_configuration.rb:
c.target_jvm_version = 1.7

C:\tmp\hello>jruby --1.9 -S rake rawr:jar
(omit output messages)

C:\tmp\hello>java -jar package\jar\hello.jar
{:a=>1, :b=>2}

Yeah, it works very well!

But after replaced the first line of main.rb like this:
h = {a: 1, b: 2}

I got the following syntax error:

C:\tmp\hello>java -jar package\jar\hello.jar
Exception in thread “main” org.jruby.exceptions.RaiseException:
(SyntaxError) ./
main.rb:1: syntax error, unexpected ‘:’

h = {a: 1, b: 2}
^
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1033)
at (Anonymous).(root)(./main.rb:1)

Umm,…
Does anyone know how to run jruby-complete.jar with 1.9 mode?

ashbb

On Fri, Apr 20, 2012 at 11:27 PM, ashbb shoeser [email protected]
wrote:

Hi all,

I’m using jruby 1.6.7, rawr 1.6.3 and JDK 7 on my Windows 7 pc.
[…]
Umm,…
Does anyone know how to run jruby-complete.jar with 1.9 mode?

I haven’t tested this out, but try this: Look in your rawr project’s
src/org/rubyforge/raw/Main.java. Before the line:

Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);

paste this:

System.setProperty(“jruby.compat.version”,
org.jruby.CompatVersion.RUBY1_9.toString());

Hi Eric,

Thank you for the information. Sorry for this late reply.

I tried your suggestion, but umm,… got the same error…

But I tried the following. It worked!

C:\tmp\hello>java -Djruby.compat.version=RUBY1_9 -jar
package\jar\lib\java\jruby-complete.jar main.rb

{:a=>1, :b=>2}

Thanks to your information, I got a solution, not using rawr, though.
:stuck_out_tongue:

ashbb

Hi Michael,

Thank you for the reply. Sorry for this late reply.

We patched warbler to send --1.9 to jrubyc when invoked in 1.9 mode, so
you might need to do the same thing for rawr.
You are right.
I’d like to improve rawr to run in 1.9 mode.
But I’ve no skill. :frowning:

I think that jruby-1.7 will default to 1.9 mode
Wow, cool!

but then the people needing 1.8 mode will encounter the same grief :frowning:
hahaha. True!
But can’t wait to use jruby-1.7!!

ashbb

Hi Ashbb,

We found a similar issue when compiling with warbler when invoking with
jruby-complete.jar. The command line arguments are not propagated to the
process that invokes jrubyc, so it always runs in the default (1.8)
mode.

We patched warbler to send --1.9 to jrubyc when invoked in 1.9 mode, so
you
might need to do the same thing for rawr. I see it uses a slightly
different mechanism for calling jrubyc, but it looks like that method
can
also take additional arguments, like the --1.9 flag (in the
file lib/rawr/jruby_batch_compiler.rb).

I think that jruby-1.7 will default to 1.9 mode, but then the people
needing 1.8 mode will encounter the same grief :frowning:

Regards,

Michael