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

Building a jar doesn't include .fxml files #8

Closed
edubkendo opened this issue Jan 7, 2013 · 8 comments
Closed

Building a jar doesn't include .fxml files #8

edubkendo opened this issue Jan 7, 2013 · 8 comments

Comments

@edubkendo
Copy link
Member

I got the "rake jar" task to run by cd'ing into my clone of the jrubyfx repo, and running it like:

jruby -S rake jar main_script=~/projects/jrubyfx_projects/Hello/src/hello2.rb

This properly built the jar for me, except it doesn't seem to include my fxml file. My hello2.rb file looks like:

require "jrubyfx"

class HelloWorldApp < JRubyFX::Application
  def start(stage)
    with(stage, title: "Hello World!", width: 800, height: 600)
    HelloWorldController.load_fxml("Hello.fxml", stage)
    stage.show()
  end
end

class HelloWorldController < JRubyFX::Controller
  fx_id :helloLabel

  fx_handler :sayClicked do
    @helloLabel.text = "You clicked me!"
  end
end

HelloWorldApp.launch

And trying to run the jar gives this error:

Exception running Application:
java.lang.IllegalStateException: Location is not set.
javafx.fxml.FXMLLoader.load(FXMLLoader.java:2021)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:440)
org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:304)
org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:52)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:306)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:136)
org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:64)
org.jruby.ast.ReturnNode.interpret(ReturnNode.java:92)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:268)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:220)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:366)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:238)
org.jruby.ast.FCallThreeArgNode.interpret(FCallThreeArgNode.java:40)
org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:225)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204)
classpath_3a_jar_minus_bootstrap.method__1$RUBY$start(classpath:jar-bootstrap.rb:6)
classpath_3a_jar_minus_bootstrap$method__1$RUBY$start.call(classpath_3a_jar_minus_bootstrap$method__1$RUBY$start)
classpath_3a_jar_minus_bootstrap$method__1$RUBY$start.call(classpath_3a_jar_minus_bootstrap$method__1$RUBY$start)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueNode.executeBody(RescueNode.java:224)
org.jruby.ast.RescueNode.interpret(RescueNode.java:119)
org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:209)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:197)
org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:128)
org.jruby.runtime.Block.call(Block.java:89)
org.jruby.RubyProc.call(RubyProc.java:261)
org.jruby.RubyProc.call(RubyProc.java:213)
org.jruby.javasupport.JavaUtil$1.call(JavaUtil.java:237)
org.jruby.javasupport.util.RuntimeHelpers$MethodMissingMethod.call(RuntimeHelpers.java:473)
org.jruby.gen.InterfaceImpl1921571541.run(org/jruby/gen/InterfaceImpl1921571541.gen:13)
com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
java.lang.Thread.run(Thread.java:722)
#
# A fatal error has been detected by the Java Runtime Environment:

And as far as I can tell, from opening up the jar, this is because the fxml file didn't seem to get included in it.

@edubkendo
Copy link
Member Author

Ok, if I unzip the jar, add in the fxml file by hand, re-zip it and rename it to .jar, it works just right so that does indeed appear to be the problem.

@byteit101
Copy link
Member

I'm going to rewrite jarification soon but this is a user error (though I don't blame you. Jaring needs better documentation)

You need to set src also, which is a pattern to match all files in your project. Main_script marks which file to load first in the jar and in the rare circumstance that it is NOT in the jar it copies it in also.

You can also manually rename your main file to jar-bootstrap.rb and only use src

@edubkendo
Copy link
Member Author

ok cool. Got it to work. Thanks for the explanation. One question. If I use:

jruby -S rake jar src="/home/eric/projects/jrubyfx_projects/Hello/src/Hello.fxml" main_script=~/projects/jrubyfx_projects/Hello/src/hello2.rb

Pointing directly to the file it works, if instead, I have src point at the containing directory, like:

jruby -S rake jar src="/home/eric/projects/jrubyfx_projects/Hello/src/" main_script=~/projects/jrubyfx_projects/Hello/src/hello2.rb

Then I get:

rake aborted!
No such file or directory - /home/eric/projects/jrubyfx_projects/Hello/src/

I'm assuming this is because you can't list directories and must list each file by hand? Or am I doing something else wrong? For the record, I also tried it without the quotes, but this received the same error.

@edubkendo
Copy link
Member Author

One last question, if you do need to list the file paths out by hand, how should you seperate those? with : 's like when constructing PATH variables?

@byteit101
Copy link
Member

Src is a PATTERN

jruby -S rake jar src="/home/eric/projects/jrubyfx_projects/Hello/src/*" main_script=~/projects/jrubyfx_projects/Hello/src/hello2.rb

@edubkendo
Copy link
Member Author

ah! you totally said that. sorry. I'll put in a pull-request with an update to the README making this stuff clear.

@byteit101
Copy link
Member

Don't. I'm updating jarification so it will change

@edubkendo
Copy link
Member Author

Ok, fair enough.

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

2 participants