about require_java

1 view
Skip to first unread message

femto gary

unread,
Apr 14, 2007, 4:11:59 AM4/14/07
to xruby...@googlegroups.com
Just some thought, how about supporting for star like 'org.antlr.runtime.*'
>>
this is the original beanworm's post:
I added a new package com.xruby.runtime.javasupport to support java
classes. Now we can introduce java classes by using require_java
method. Here's an example:

require_java 'org.beanworms.test.Talker'


t = Talker.new
t.talk "XRuby"
t.talk "Mr.", "XRuby"

Xue Yong Zhi

unread,
Apr 14, 2007, 11:23:29 PM4/14/07
to xruby...@googlegroups.com
beanworms wrote this and probably the only one familiar with it. He is on a
business trip now, and may not be able to reply soon.

_________________________________________________________________
Need a break? Find your escape route with Live Search Maps.
http://maps.live.com/?icid=hmtag3

bean...@gmail.com

unread,
Apr 14, 2007, 11:45:14 PM4/14/07
to xruby-devel
Hi,
To support wildcard is a good idea. :)

Thanks
Yu Su

feiyu

unread,
May 17, 2007, 12:10:53 PM5/17/07
to xruby-devel
It support wildcard now! You can write code like this:

import "java.util.*"

r = Random.new
puts r.nextInt

array = ArrayList.new
array.add 1
array.add 2
array.add 3
for i in 1 ... 3
puts array.get(i)
end

Although import the whole package,but not import all classes right
now. Every class in the package only be imported in need.This is
accomplished throught hacking code in
RubyAPI#getCurrentNamespaceConstant method.

feiyu

unread,
May 17, 2007, 12:23:46 PM5/17/07
to xruby-devel

"import" is "require_java"'s alias.As a Java programmer,I fee that
"import" is more friendliness.

femto

unread,
May 17, 2007, 9:40:25 PM5/17/07
to xruby-devel
hi feiyu, actually I feel require is better,
because we are following ruby wisdom here but not java wisdom.
Thanks for the effort:)
And do you know how spring handles classpath searching
like classpath:com/xruby/**/ etc? Just a ask.

dreamhead

unread,
May 17, 2007, 10:48:12 PM5/17/07
to xruby...@googlegroups.com
I've developed a function like this. Just search jar or directory for
.class file. It sucks but works.

I agree with femto that import is more Java rather than Ruby.

2007/5/18, femto <femt...@gmail.com>:


--
Everything is simple!

femto

unread,
May 17, 2007, 11:26:59 PM5/17/07
to xruby-devel
search jar or directory, yeap.
but spring uses classpath:**, so how do I know where in the classpath
has how many jars or directorys? Do Java have support for this?

On May 18, 10:48 am, dreamhead <dreamhead...@gmail.com> wrote:
> I've developed a function like this. Just search jar or directory for
> .class file. It sucks but works.
>
> I agree with femto that import is more Java rather than Ruby.
>

> 2007/5/18, femto <femto...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages