[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Syntax to include custom Java classes

thiagobrandam

10/4/2008 4:04:00 PM

Hi guys. This is a newbie's question: how do I do to include custom
Java classes in a .rb file? Do I have to make a .jar file and then
call a require? If so, what's the next thing I have to do to use a
Java class in the same .rb file? Thanks in advance.
6 Answers

thiagobrandam

10/4/2008 7:28:00 PM

0

I figured out how to do.

On Oct 4, 1:03=A0pm, thiagobrandam <thiagobran...@gmail.com> wrote:
> Hi guys. This is a newbie's question: how do I do to include custom
> Java classes in a .rb file? Do I have to make a .jar file and then
> call a require? If so, what's the next thing I have to do to use a
> Java class in the same .rb file? Thanks in advance.

James Britt

10/5/2008 12:16:00 AM

0

thiagobrandam wrote:
> I figured out how to do.

Side note: There's a good change that if one person has a question
about something, then someone else will, too.

If you found an answer for your problem it would be helpful to post it
here so that others can find it or reference it.

(There's another matter of whether the original question would have been
better asked on the JRuby list, but here it is, so ...)



--
James Britt

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

thiagobrandam

10/5/2008 2:08:00 AM

0

I don't know if this is the best way but here it goes:

Every .class file that has a correspondent class I may use in a .rb
file, I can merge them in a .jar file. Then, I just have to call
require 'name_of_the_file.jar' (if it's in the same directory). To use
a particular class, say ClassName, just call import 'ClassName'.
Everything else is pretty much the same as though you were only using
Ruby (except for the fact that you must use jruby to interpret).

As for whether it would be better in a jruby list, I didn't know that
the scope of this one was MRI solely. Next time I'll think twice
before posting newbie questions in the wrong places. Sorry for any
incovenience.

Thiago

On Oct 4, 9:15=A0pm, James Britt <james.br...@gmail.com> wrote:
> thiagobrandam wrote:
> > I figured out how to do.
>
> Side note: =A0There's a good change that if one person has a question
> about something, then someone else will, too.
>
> If you found an answer for your problem it would be helpful to post it
> here so that others can find it or reference it.
>
> (There's another matter of whether the original question would have been
> better asked on the JRuby list, but here it is, so ...)
>
> --
> James Britt
>
> www.happycamperstudios.com=A0 - Wicked Cool Codingwww.jamesbritt.com=A0 =
=A0 =A0 =A0 =A0 - Playing with Better Toyswww.ruby-doc.org=A0 =A0 =A0 =A0 =
=A0 =A0 - Ruby Help & Documentationwww.rubystuff.com=A0 =A0 =A0 =A0 =A0 =A0=
- The Ruby Store for Ruby Stuff

James Britt

10/5/2008 3:49:00 AM

0

thiagobrandam wrote:
> I don't know if this is the best way but here it goes:
>
> Every .class file that has a correspondent class I may use in a .rb
> file, I can merge them in a .jar file. Then, I just have to call
> require 'name_of_the_file.jar' (if it's in the same directory). To use
> a particular class, say ClassName, just call import 'ClassName'.
> Everything else is pretty much the same as though you were only using
> Ruby (except for the fact that you must use jruby to interpret).


Cool! Thanks.

>
> As for whether it would be better in a jruby list, I didn't know that
> the scope of this one was MRI solely. Next time I'll think twice
> before posting newbie questions in the wrong places. Sorry for any
> incovenience.

No inconvenience, and I also don't know if JRuby questions are welcome
here or not. The list is ruby-talk, not c-ruby-talk or mri-talk, so I
vote Yes on general JRuby usage questions.

(Of course, I do a lot of work with JRuby, so I'm biased. But Ruby is
Ruby, and this list seems amenable to question on using C extensions and
such, so I think we're all good.)

--
James Britt

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

Robert Dober

10/5/2008 7:58:00 AM

0

On Sun, Oct 5, 2008 at 5:48 AM, James Britt <james.britt@gmail.com> wrote:

> Cool! Thanks.
I agree this was useful info, I played around with this and had some
difficulties.
>
>>
>> As for whether it would be better in a jruby list, I didn't know that
>> the scope of this one was MRI solely. Next time I'll think twice
>> before posting newbie questions in the wrong places. Sorry for any
>> incovenience.
>
> No inconvenience, and I also don't know if JRuby questions are welcome h=
ere
> or not. The list is ruby-talk, not c-ruby-talk or mri-talk, so I vote Ye=
s
> on general JRuby usage questions.
Well the JRuby list might have be the place to look for an answer but
I agree that this list is general enough to share it or
even ask for it, so yes I share James' POV here.

Thanks again and just another point. Unless you have a very good
reason to top post please try bottom or inline posting the next time.
This is a long established practice on this list. No big deal however.

Cheers
Robert
--=20
C'est v=E9ritablement utile puisque c'est joli.

Antoine de Saint Exup=E9ry

thiagobrandam

10/5/2008 1:02:00 PM

0



> Thanks again and just another point. Unless you have a very good
> reason to top post please try bottom or inline posting the next time.
> This is a long established practice on this list. No big deal however.

Sorry guys, I'm not used to it. I'll obey the rules of the list.
Thanks for the help.