wood burning stoves 2.0*
The moose likes Other Languages and the fly likes JRuby Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Other Languages
Bookmark "JRuby" Watch "JRuby" New topic
Author

JRuby

Arno Reper
Ranch Hand

Joined: Mar 14, 2006
Posts: 286
Hello,
I don't know if it's here the right place for asking about JRuby...but like you read it's too late ;-)
Here is my question, for school I had to develop a Snake ( a game...like the one on mobile ). I choose to write it in java. We have to use a special collection type, a sparse matrix. I write it too and it works. The thing is I finished the project too fast...so I was thinking of writing my snake in Ruby (only the non-Gui code ) but I don't know very well how to mix java and ruby when I'm using JRuby.
I only want to reuse my JFrame and maybe also the GameScheduler.
So if someone has knowledge about that...thank you very much for your help.
Arno


The man who makes no mistakes does not usually make anything<br /> <br />>>> SCJP 5.0 >> SCJD B&S <<< In progress
Arno Reper
Ranch Hand

Joined: Mar 14, 2006
Posts: 286
Ups i didn't see the OOScripting forum ...my apologizes, if someone want to move my post


ps: thanks for moving...
[ November 20, 2006: Message edited by: Arno Reper ]
Arno Reper
Ranch Hand

Joined: Mar 14, 2006
Posts: 286
Nobody using JRuby out there?
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Well, are you trying to use ruby from java or java from ruby? Using java classes in jruby code is really simple.

On the jruby download page there is a powerpoint with some code examples, here's one:



Here is some more info I found using google:

calling java from jruby from the wiki

java integration from wiki

bsf example from old jruby site
[ November 23, 2006: Message edited by: Carol Enderlin ]
Arno Reper
Ranch Hand

Joined: Mar 14, 2006
Posts: 286
thank you very much for your help...
i will try this...
what i did was only use require'java' and then f.e JFrame = java.swing.JFrame
JFrame.new()
but it didn't really work :roll:

Its for using my java classes into my Ruby code...
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Make sure you've got the latest version, 0.91. They simplified the syntax for using java classes. That is mentioned on the link above, calling java from jruby.

Arno Reper
Ranch Hand

Joined: Mar 14, 2006
Posts: 286
hello,
i use 0.9.1...but now i have another problem :roll:
Do you know how i can modify the classpath to include my java source because i get this message :

ar is my package...
thanks
Arno Reper
Ranch Hand

Joined: Mar 14, 2006
Posts: 286


i tryed that but it didn't work...
Shame on me...Im SCJP and I can'nt change my cp argh...
[ November 26, 2006: Message edited by: Arno Reper ]
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
set your classpath so that your ar.Snake class can be found, don't worry about jruby.jar, and run the jruby command not the java command.

HowToSetTheClasspath from JavaRanch FAQ

[ November 26, 2006: Message edited by: Carol Enderlin ]

f you are trying to locate classes in a directory, then specify the path up to but not including the name of the package the classes are in. (If the classes are in a package called my.package and they are located in a directory called C:\myclasses\here\my\package, you would set the classpath to be CLASSPATH=C:\myclasses\here).

[ November 26, 2006: Message edited by: Carol Enderlin ]
 
Don't get me started about those stupid light bulbs.
 
subject: JRuby