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

689dae2a2a14404ed27048633f472147?d=identicon&s=25 ashbb shoeser (satoshi_a)
on 2012-04-21 06:27
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
Abdb670e1c130f96f947a94d03c02efa?d=identicon&s=25 Eric Christopherson (echristopherson)
on 2012-04-21 18:58
(Received via mailing list)
On Fri, Apr 20, 2012 at 11:27 PM, ashbb shoeser <lists@ruby-forum.com>
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());
1272e095e145697bb0371230688bd2c3?d=identicon&s=25 Michael Pitman (mcp)
on 2012-04-23 12:48
(Received via mailing list)
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 :(

Regards,

Michael
689dae2a2a14404ed27048633f472147?d=identicon&s=25 ashbb shoeser (satoshi_a)
on 2012-04-26 13:45
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.
:-P

ashbb
689dae2a2a14404ed27048633f472147?d=identicon&s=25 ashbb shoeser (satoshi_a)
on 2012-04-26 14:01
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. :(

> 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 :(
hahaha. True!
But can't wait to use jruby-1.7!!

ashbb
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.