【发布时间】:2013-02-05 12:07:22
【问题描述】:
在 Windows 上将 Pry gem 与 JRuby 和 JRubyFx 一起使用的正确方法是什么?
我正在使用 JRubyFx(一个 JavaFX JRuby 绑定 - https://github.com/jruby/jrubyfx),在我的测试中,我使用的这个 example 缩小到了最少的必要行数。
require 'jrubyfx'
require 'pry'
class SimpleFXApplication < JRubyFX::Application
def start(stage)
stage.title = "jrubyfx app"
@ctrlr = SimpleFXController.load_fxml("some_fxml_code_for_ui.fxml", stage)
stage.show
end
end
class SimpleFXController < JRubyFX::Controller
end
SimpleFXApplication.launch
binding.pry
启动应用程序后,控制台不再接受输入,“pry”仅在我关闭 SimpleFXApplication 窗口时才返回接受输入。
我也尝试过使用 Java 线程:
...
binding.pry
Java.java.lang.Thread.new do SimpleFXApplication.launch end
但是,尽管新线程 id 显示为正在运行,但 SimpleFXApplication 永远不会启动。
我尝试的另一件事是从控制台开始 pry,然后要求并启动 SimpleFXApplication:
jruby -S 撬
需要'./jrubyfx_demo.rb'
是的
SimpleFXApplication.launch
我收到以下错误...
异常运行应用程序:java.net.MalformedURLException:未知 协议:c java.net.URL。(未知来源) java.net.URL.(未知来源) sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知 来源)java.lang.reflect.Constructor.newInstance(未知来源) org.jruby.javasupport.JavaConstructor.newInstanceDirect(JavaConstructor.java:291) org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:104) org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:197) org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:211) org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:217) org.jruby.java.proxies.ConcreteJavaProxy$2.call(ConcreteJavaProxy.java:56) org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:211) org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:217) org.jruby.RubyClass.newInstance(RubyClass.java:862) org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen) org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrTwoOrNBlock.call(JavaMethod.java:295) org.jruby.java.proxies.ConcreteJavaProxy$3.call(ConcreteJavaProxy.java:155) org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346) org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204) org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59) org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) org.jruby.ast.BlockNode.interpret(BlockNode.java:71) org.jruby.ast.IfNode.interpret(IfNode.java:118) org.jruby.ast.AttrAssignOneArgNode.interpret(AttrAssignOneArgNode.java:33) 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) org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59) org.jruby.ast.InstAsgnNode.interpret(InstAsgnNode.java:95) 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:182) org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:188) 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:445) org.jruby.gen.InterfaceImpl1014569521.run(org/jruby/gen/InterfaceImpl1014569521.gen:13) com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215) com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179) com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176) java.security.AccessController.doPrivileged(本机方法) com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176) com.sun.glass.ui.win.WinApplication._runLoop(本机方法) com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29) com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73) java.lang.Thread.run(未知来源) => 无
我猜这与 JrubyFx 如何使用线程有关,或者我不知道这是否是一个更普遍的问题会影响 JRuby 的 Pry 使用。 我想知道更多,如果有人可以分享一些建议,我将不胜感激。
【问题讨论】:
-
请显示您使用的代码。
-
谢谢,我添加了代码和更好的问题描述。
-
“some_fxml_code_for_ui.fxml”的完整路径是什么?
-
路径对于示例来说太嵌套了,所以我将 'jrubyfx_demo.rb' 和 'some_fxml_code_for_ui.fxml' 都移到了 'c:\example\app' 中,并从那里运行了相同的代码,但是我有同样的结果
标签: windows jruby javafx-2 pry