JRuby Basic Sanity Fails?

38 views
Skip to first unread message

JRuby

unread,
Jul 27, 2011, 4:48:28 PM7/27/11
to rawr-lib
Pulling my hair out on this one -- can't seem to get the equivalent of
"hello world" to work. Was working on a larger project, had some
difficulties and tried a small skeleton:


jruby@jruby:~/hello_rawr$ cd ..
jruby@jruby:~$ mkdir hello_rawr
jruby@jruby:~$ cd hello_rawr/
jruby@jruby:~/hello_rawr$ rawr install
Running in jruby 1.6.3 (ruby-1.8.7-p330) [linux-amd64-java]
Create rawr files using {:wordy=>false,
:class=>"org.rubyforge.rawr.Main",
:directory=>"src",
:build_config_file=>"build_configuration.rb",
:local_jruby_jar=>nil,
:no_config=>"false",
:show_version=>false,
:no_download=>"false",
:no_jar=>"false",
:command=>["install"]}

write config file
Creating Rawr configuration file build_configuration.rb
option project_name: hello_rawr
option output_dir: package
option main_ruby_file: main
option main_java_file: org.rubyforge.rawr.Main
option source_dirs: src
option source_exclude_filter:
option compile_ruby_files: true
option java_lib_files:
option java_lib_dirs: lib/java
option files_to_copy:
option target_jvm_version: 1.6
option jvm_arguments:
option java_library_path:
option extra_user_jars:
option mac_do_not_generate_plist:
option mac_icon_path:
option windows_icon_path:
Creating Java class /home/jruby/hello_rawr/src/org/rubyforge/rawr/
Main.java
Creating Rakefile ...
Downloading jruby-complete.jar. This may take a moment...
All done!
jruby@jruby:~/hello_rawr$ cat > src/main.rb
puts "hello world!"
jruby@jruby:~/hello_rawr$ rake rawr:jar
(in /home/jruby/hello_rawr)
mkdir -p package/classes/java
javac -target 1.6 -cp lib/java/jruby-complete.jar:src -sourcepath src -
d package/classes/java src/org/rubyforge/rawr/Main.java
mkdir -p package/classes/ruby
Compile src/main.rb into package/classes/ruby/main.class
compile_dirs has src_dirs = ["src"]
glob_ruby_files has directory 'src' glob ["src/main.rb"]
files for src: 1
ruby_globs.each has glob_data = #<OpenStruct files=["main.rb"],
directory="src">
Go compile ["src/main.rb"]
mkdir -p package/classes/META-INF
mkdir -p package/jar
=== Creating jar file: package/jar/hello_rawr.jar
cp lib/java/jruby-complete.jar package/jar/lib/java/jruby-
complete.jar
jruby@jruby:~/hello_rawr$ java -jar ./package/jar/hello_rawr.jar
Exception in thread "main" org.jruby.exceptions.RaiseException:
(LoadError) no such file to load -- main
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:
1038)
at #<Class:0x15b14a306>.(root)(<script>:1)
jruby@jruby:~/hello_rawr$

This is with jruby 1.6.3 (ruby-1.8.7-p330) (2011-07-07 965162f)
(OpenJDK 64-Bit Server VM 1.6.0_22) [linux-amd64-java]

James Britt

unread,
Aug 1, 2011, 12:10:01 PM8/1/11
to rawr...@googlegroups.com
JRuby wrote:
> Pulling my hair out on this one -- can't seem to get the equivalent of
> "hello world" to work. Was working on a larger project, had some
> difficulties and tried a small skeleton:
>
-- snip --

> jruby@jruby:~/hello_rawr$ java -jar ./package/jar/hello_rawr.jar
> Exception in thread "main" org.jruby.exceptions.RaiseException:
> (LoadError) no such file to load -- main
> at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:
> 1038)
> at #<Class:0x15b14a306>.(root)(<script>:1)


I just tried this and got the same results. I need to poke around and
see why this is.

I looked in the hello_world.jar file and main.class is there, but
obvioulsy being ignored


James Britt

James Britt

unread,
Aug 1, 2011, 1:38:38 PM8/1/11
to rawr...@googlegroups.com

As an experiment I edited build_configuration.rb and changed the
value of the main ruby file:

c.main_ruby_file = "src/main"

I re-jarred and it ran fine.

Exactly *why* this is needed when it obviously used to work before
without the explicit path I need to determine.

James

Reply all
Reply to author
Forward
0 new messages