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

[windows 7] Accessing and Importing Java Classes From jar files #3390

Closed
belgoros opened this issue Oct 12, 2015 · 4 comments
Closed

[windows 7] Accessing and Importing Java Classes From jar files #3390

belgoros opened this issue Oct 12, 2015 · 4 comments

Comments

@belgoros
Copy link

I tried to import a jar as explained on the wiki page: https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby but failed:

require 'java'
require 'jars/commons-lang3-3.4.jar'

include_class org.apache.commons.lang3.StringUtils
...

When running a ruby file from the console, it gives the below error:

C:\Users\XXXXX\Documents\projects\ruby_drafts\lib>jruby draft.rb
LoadError: no such file to load -- jars/commons-lang3-3.4
  require at org/jruby/RubyKernel.java:939
  require at C:/jruby-9.0.1.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
    <top> at draft.rb:2

As you see, the ruby script is in lib folder, the jar to load is in lib/jarsfolder.

Reproduced on a Windows 7 PC, JRuby version:

jruby 9.0.1.0 (2.2.2) 2015-09-02 583f336 Java HotSpot(TM) 64-Bit Server VM 24.79-b02 on 1.7.0_79-b15 +jit [Windows 7-amd64]

Any idea ? Thank you.

@mkristian
Copy link
Member

the current directory is not automatically (anymore) on the $LOAD_PATH. you have to add it yourself:

jruby -I. draft.rb

@belgoros
Copy link
Author

Does it concern Windows only ? Because I have no problems with the same script on OS X.

@mkristian
Copy link
Member

does help on windows ?

the current directory could be on the classpath on OS X and not on windows. not sure how to check this.

@belgoros
Copy link
Author

OK, thank you. It worked for me.

@enebo enebo added this to the Invalid or Duplicate milestone Oct 13, 2015
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