Is there any way to "be equivalent to" the package declaration in a .java file? Something like this in java: package org.familysearch.digitalarchive.tapeingestreader; in ruby becomes something like java_import "org.familysearch.digitalarchive.tapeingestreader.*" Thanks. -r
on 2010-09-09 19:41
on 2010-09-15 19:41
> package org.familysearch.digitalarchive.tapeingestreader; > > in ruby becomes something like > > java_import "org.familysearch.digitalarchive.tapeingestreader.*" Looks like it's not possible in the global namespace (?) but is within a module. module M; include_package "org.familysearch.digitalarchive.tapeingestreader"; end Anybody know how to do this into the global namespace? Or to somehow enumerate the java classes within a package, so you can fake it? -r
on 2010-09-28 20:30
> Anybody know how to do this into the global namespace? Or to somehow > enumerate the java classes within a package, so you can fake it? Looks like it is possible, like this: module M include_package "javax.swing" include_package "java.awt" include_package "java.awt.image" # BufferedImage BufferedImage end class Object class << self alias :const_missing_old :const_missing def const_missing c M.const_get c end end end BufferedImage # works JFrame # works You'd think that this would work, as well: require'java' module M include_package "javax.swing" include_package "java.awt" include_package "java.awt.image" # BufferedImage BufferedImage end include M BufferedImage # works JFrame # this line fails Is this a bug? possibly related: http://jira.codehaus.org/browse/JRUBY-5107 Thanks! -r
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.