Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Error "cannot load Java class"

Reply
Thread Tools

Error "cannot load Java class"

 
 
Ahmed Abdelsalam
Guest
Posts: n/a
 
      04-23-2009
I've created two java classes that I'm trying to call from ruby file. I
put the java classes with the ruby file in the same directory, and tried
to run.

I accessed java classes from the ruby file using full class path like:
Java::com.ch.Cells

but I got the following error:
org.jruby.exceptions.RaiseException: cannot load Java class
com.ch.Cells
at
com.sun.script.jruby.JRubyScriptEngine.evalNode(JR ubyScriptEngine.java:456)
at
com.sun.script.jruby.JRubyScriptEngine.eval(JRubyS criptEngine.java:186)
at javax.script.AbstractScriptEngine.eval(Unknown Source)

Caused by: org.jruby.exceptions.RaiseException: cannot load Java class
com.ch.Cells
at (unknown).(unknown)(/builtin/java/ast.rb:49)
at
(unknown).get_proxy_or_package_under_package(/builtin/javasupport/java.rb:51)
at #<Class:01x965654>.method_missing(<unknown>:1)
at (unknown).(unknown)(:1)


Any help !!!
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Chuck Remes
Guest
Posts: n/a
 
      04-23-2009

On Apr 23, 2009, at 5:22 AM, Ahmed Abdelsalam wrote:

> I've created two java classes that I'm trying to call from ruby
> file. I
> put the java classes with the ruby file in the same directory, and
> tried
> to run.
>
> I accessed java classes from the ruby file using full class path like:
> Java::com.ch.Cells
>
> but I got the following error:
> org.jruby.exceptions.RaiseException: cannot load Java class
> com.ch.Cells
> at
> com
> .sun.script.jruby.JRubyScriptEngine.evalNode(JRuby ScriptEngine.java:
> 456)
> at
> com.sun.script.jruby.JRubyScriptEngine.eval(JRubyS criptEngine.java:
> 186)
> at javax.script.AbstractScriptEngine.eval(Unknown Source)
>
> Caused by: org.jruby.exceptions.RaiseException: cannot load Java class
> com.ch.Cells
> at (unknown).(unknown)(/builtin/java/ast.rb:49)
> at
> (unknown).get_proxy_or_package_under_package(/builtin/javasupport/
> java.rb:51)
> at #<Class:01x965654>.method_missing(<unknown>:1)
> at (unknown).(unknown)(:1)


You need to show us the code too. Show the Java and show the ruby.

cr


 
Reply With Quote
 
 
 
 
Ahmed Abdelsalam
Guest
Posts: n/a
 
      04-23-2009
Chuck Remes wrote:
> On Apr 23, 2009, at 5:22 AM, Ahmed Abdelsalam wrote:
>
>> org.jruby.exceptions.RaiseException: cannot load Java class
>> Caused by: org.jruby.exceptions.RaiseException: cannot load Java class
>> com.ch.Cells
>> at (unknown).(unknown)(/builtin/java/ast.rb:49)
>> at
>> (unknown).get_proxy_or_package_under_package(/builtin/javasupport/
>> java.rb:51)
>> at #<Class:01x965654>.method_missing(<unknown>:1)
>> at (unknown).(unknown)(:1)

>
> You need to show us the code too. Show the Java and show the ruby.
>
> cr


Here is the ruby code:
class Cells < Java::cz.cesnet.meta.jruby.Cells
def initialize
@cells = {'a1' => 'Hello a1'};
end
end

here is the java code:
ScriptEngineManager m = new ScriptEngineManager();

// Override due to classpath troubles with OSGi ?
m.registerEngineName("jruby",
new com.sun.script.jruby.JRubyScriptEngineFactory());

//get jruby engine
ScriptEngine jruby = m.getEngineByName("jruby");
//process a ruby file
jruby.eval(new BufferedReader(new FileReader("... path to ruby
file")));
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Balancing / Load Sharing over parallel paths ciscortp@hotmail.com Cisco 1 11-21-2005 03:57 PM
page not load / freeze / long time to load roni ASP .Net 1 08-30-2005 09:15 PM
Page Load and webcontrol page load venky ASP .Net 5 07-11-2005 03:16 PM
Java applet failed when I try to load the avi file in my java applet Krista Java 3 09-15-2004 02:53 AM
beginning page load immediately on postback with a long load time ? Mad Scientist Jr ASP .Net 7 06-30-2004 07:40 PM



Advertisments