Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you load a java class whose name is all caps? #3743

Closed
neojin opened this issue Mar 17, 2016 · 3 comments
Closed

How do you load a java class whose name is all caps? #3743

neojin opened this issue Mar 17, 2016 · 3 comments

Comments

@neojin
Copy link

neojin commented Mar 17, 2016

Environment

jruby-1.7.23, jruby-9.0.5.0

Expected Behavior

The java class is defined and available for use in jruby

Actual Behavior

Ex: java class loading properly (because it is camel cased):

irb(main):001:0> require 'java'
irb(main):002:0> require Rails.root.join 'lib', 'lwjgl.jar'

irb(main):003:0> org.lwjgl.openal.ALUtil
=> Java::OrgLwjglOpenal::ALUtil
irb(main):004:0> org.lwjgl.openal.ALUtil.checkALError()
# runs fine

Ex: java class with all caps:

jruby-1.7.23:

irb(main):006:0> org.lwjgl.glfw.GLFW
NameError: cannot link Java class org.lwjgl.glfw.GLFW (java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.glfw.GLFW)
    from org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package'
    from file:/Users/jinlee/.rbenv/versions/jruby-1.7.23/lib/jruby.jar!/jruby/java/java_package_module_template.rb:14:in `method_missing'
    from (irb):6:in `evaluate'
    from org/jruby/RubyKernel.java:1079:in `eval'
    from org/jruby/RubyKernel.java:1479:in `loop'
    from org/jruby/RubyKernel.java:1242:in `catch'
    from org/jruby/RubyKernel.java:1242:in `catch'
    from /Users/jinlee/.rbenv/versions/jruby-1.7.23/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
    from /Users/jinlee/.rbenv/versions/jruby-1.7.23/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
    from /Users/jinlee/.rbenv/versions/jruby-1.7.23/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/jinlee/.rbenv/versions/jruby-1.7.23/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/jinlee/.rbenv/versions/jruby-1.7.23/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands.rb:17:in `(root)'
    from org/jruby/RubyKernel.java:1040:in `require'
    from bin/rails:4:in `(root)'

jruby-9.0.5.0:

irb(main):004:0* org.lwjgl.glfw.GLFW
NameError: cannot link Java class org.lwjgl.glfw.GLFW (java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path)
    from org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package'
    from uri:classloader:/jruby/java/java_package_module_template.rb:14:in `method_missing'
    from (irb):4:in `<eval>'
    from org/jruby/RubyKernel.java:976:in `eval'
    from org/jruby/RubyKernel.java:1287:in `loop'
    from org/jruby/RubyKernel.java:1096:in `catch'
    from org/jruby/RubyKernel.java:1096:in `catch'
    from /Users/jinlee/.rbenv/versions/jruby-9.0.5.0/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
    from /Users/jinlee/.rbenv/versions/jruby-9.0.5.0/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
    from /Users/jinlee/.rbenv/versions/jruby-9.0.5.0/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/jinlee/.rbenv/versions/jruby-9.0.5.0/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/jinlee/.rbenv/versions/jruby-9.0.5.0/lib/ruby/gems/shared/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top>'
    from org/jruby/RubyKernel.java:937:in `require'
    from bin/rails:4:in `<top>'

The class in question:
http://javadoc.lwjgl.org/org/lwjgl/glfw/GLFW.html

@enebo
Copy link
Member

enebo commented Mar 17, 2016

JRuby 9 might be telling you what is wrong in this error:

java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

Have you set up -J-Djava.library.path=my_path_tolwjgl.so?

@neojin
Copy link
Author

neojin commented Mar 17, 2016

Well, I'm an idiot. Thanks so much for this, and apologies for the extra noise.

To anyone else seeing this, I did the following:

export JAVA_OPTS="-Djava.library.path=/path/to/native/libraries/"
# run the program

@neojin neojin closed this as completed Mar 17, 2016
@kares kares added this to the Invalid or Duplicate milestone Mar 18, 2016
@enebo
Copy link
Member

enebo commented Mar 18, 2016

@neojin no problem you are not the first to run into this and you won't be the last. java.library.path is a weird thing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants