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

jarify with fxml: require_relative doesn't work from inside a jarfile #117

Open
brucetesar opened this issue Jul 15, 2017 · 0 comments
Open

Comments

@brucetesar
Copy link

Issue
After jarifying samples\fxml\Demo.rb, executing the jar file produces a LoadError for the require_relative statement in Demo.rb (around line 21). More precisely, the line
require_relative 'complex_control'
results in the error message
LoadError: no such file to load -- classpath:C:/complex_control

My guess is that this has something to do with the behavior of __FILE__ inside of a jar. If require_relative is implemented by referring to __FILE__, and __FILE__ doesn't behave properly inside a jar, that would help explain the trouble. The drive designation "C:" that appears in the error message does not appear when I call __FILE__, so I don't know where that comes from.

Workaround
In Demo.rb, replace the line
require_relative 'complex_control'
with the following lines:

    if JRubyFX::Application.in_jar? then
      require 'complex_control'
    else
      require_relative 'complex_control'
    end

In the jar execution, using require seems to work. I have not tried to test this with instances of require_relative anywhere else (for instance in a file in a directory below the root of the jar file).

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

1 participant