[jruby-user] cannot load Java class jline.console.ConsoleReader

18 views
Skip to first unread message

Khirod Patra

unread,
May 20, 2014, 3:36:13 AM5/20/14
to us...@jruby.codehaus.org
JRUBY : 1.7.8


I am getting the classloader issue for jline. When I tired to debug with
pry it load the jline class successfully , but without debug mode it
just failed to load the class.

Other related information:
-----------------------------

I am using my project.jar which have included
jruby-core-complete-1.7.8.jar and jruby-stdlib-complete-1.7.8.jar. I
checked manually the jline package included in the
jruby-stdlib-complete-1.7.8.jar, but the log says it looks from
jruby-core-complete-1.7.8.jar , not sure. Please help.



Log:
----------

[2014-05-20 10:42:34] ERROR Object: <NameError> cannot load Java class
jline.console.ConsoleReader
org/jruby/javasupport/JavaClass.java:1250:in `for_name'
org/jruby/javasupport/JavaUtilities.java:34:in `get_proxy_class'
file:/tmp/jruby882017107996340294extract/jruby-core-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:26:in
`java_import'
org/jruby/RubyArray.java:2413:in `map'
file:/tmp/jruby882017107996340294extract/jruby-core-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:22:in
`java_import'


Thanks
-Khirod

--
Posted via http://www.ruby-forum.com/.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Khirod Patra

unread,
May 20, 2014, 3:41:45 AM5/20/14
to us...@jruby.codehaus.org
I just tried with set the CLASSPATH for jruby-complete-1.7.8.jar
externaly, but still it is failing with same reason.

2014-05-20 13:09:07] ERROR Object: <NameError> cannot load Java class
jline.console.ConsoleReader
org/jruby/javasupport/JavaClass.java:1250:in `for_name'
org/jruby/javasupport/JavaUtilities.java:34:in `get_proxy_class'
file:/home/eip/installer/lib/jruby-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:26:in
`java_import'
org/jruby/RubyArray.java:2413:in `map'
file:/home/eip/installer/lib/jruby-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:22:in
`java_import'


-khirod

Khirod Patra

unread,
May 20, 2014, 3:55:18 AM5/20/14
to us...@jruby.codehaus.org
Now , I just extract the jline.jar from jruby-complete-1.7.8.jar and
export in the CLASSPATH externally and it works fine. But I want to use
the jline from jruby-complete-1.7.8.jar. Please help!

christian

unread,
May 20, 2014, 4:00:15 AM5/20/14
to us...@jruby.codehaus.org
when I execute something like this:

$ java -jar jruby-complete-1.7.8.jar -e 'p require"readline";p $CLASSPATH'

things looks OK on my side. how do you execute jruby ?

does it help if you require 'readline/jline-2.11' explicitly - something like

$ java -jar jruby-complete-1.7.8.jar -e 'p require"readline/jline-2.11";p $CLASSPATH'

?

Khirod Patra

unread,
May 20, 2014, 7:36:19 AM5/20/14
to us...@jruby.codehaus.org
Hi Christian,

Thanks for your help. I tried your command it works fine in prompt. How
can I used it my code? Do I have to use always pry , can't we load the
class without pry.Please help.



java -jar jruby-complete-1.7.8.jar -e 'p require "readline/jline-2.11";p
$CLASSPATH'
true

christian

unread,
May 20, 2014, 7:50:54 AM5/20/14
to us...@jruby.codehaus.org
just add

require 'readline/jline-2.11'

before you want to use jline classes. let me know if that solves your problem so I can improve things on the jruby side of things.

Khirod Patra

unread,
May 20, 2014, 7:53:23 AM5/20/14
to us...@jruby.codehaus.org
Hi Christian,

In the code I tried

p require "readline/jline-2.11"
p $CLASSPATH

It loaded successfully i.e.

true

["file:/home/Khirod/myproject/lib/ojdbc6.jar",
"file:/home/Khirod/myproject/lib/jruby-complete-1.7.8.jar",
"file:/home/Khirod/myproject/lib/mycustom.jar",
"jar:file:/tmp/jruby5839733601718663013extract/jruby-stdlib-complete-1.7.8.jar!/META-INF/jruby.home/lib/ruby/shared/readline/jline-2.11.jar"]

I used the java_import to load ConsoleReader i.e.

java_import 'jline.console.ConsoleReader' Here it is still failed to
load the class jline.console.ConsoleReader.

christian

unread,
May 20, 2014, 8:10:20 AM5/20/14
to us...@jruby.codehaus.org
I am sure this works for you as well:

java -jar /usr/local/repository/org/jruby/jruby-complete/1.7.8/jruby-complete-1.7.8.jar t.rb -e "require 'readline';java_import 'jline.console.ConsoleReader'; p ConsoleReader.new"


from your classpath above I see jruby-stdlib-complete-1.7.8.jar and jruby-complete-1.7.8.jar - there is something TOO much. jruby-complete is jruby-core-complete + jruby-stdlib-complete ! so when you are using jruby-complete please leave those other jars out of the classpath. hope that helps you a step further ;)


Khirod Patra

unread,
May 20, 2014, 12:02:36 PM5/20/14
to us...@jruby.codehaus.org
Thanks Christian,

The tricks works. Thanks for your suggestions.
Reply all
Reply to author
Forward
0 new messages