I just started using JRuby and I create a small test file:
f = File.new ARGV
When I run the program like so:
jruby test.rb file.txt
I get the following warning:
/Library/Frameworks/JRuby.framework/Versions/1.6.5/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/object.rb:99 warning: already initialized constant File
The class of
f is in fact the java File class, but I still get the warning, any help??
I found out this is related to the following JRuby ticket by looking in object.rb:
Seems like a reasonable warning to me, since Ruby already has a File class (i.e. the constant "File" was already initialized to refer to the Ruby File class).
Myself, I would probably skip the import and just do
require 'java' f = java.io.File.new ARGV
which should work and would eliminate name clashes.
You can also do
require 'java' java_file = java.io.File f = java_file.new ARGV
module JavaIO include_package "java.io" end f = JavaIO::File.new ARGV