title: Jruby: using Pry with JRuby (and JRubyFx)
body: <p><strong>What is the correct way to use Pry gem with JRuby and JRubyFx on windows?</strong> </p>
  
  <p>I am using the JRubyFx (a JavaFX JRuby binding - <a href="https://github.com/jruby/jrubyfx" rel="nofollow">https://github.com/jruby/jrubyfx</a>) and for my test I am using this <a href="https://github.com/jruby/jrubyfx/blob/master/samples/fxml/Demo.rb" rel="nofollow">example</a> shrinked to the minimum necessary lines.</p>
  
  <pre><code>require 'jrubyfx'
  require 'pry'
  
  class SimpleFXApplication &lt; 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 &lt; JRubyFX::Controller
  end
  
  SimpleFXApplication.launch
  binding.pry
  </code></pre>
  
  <p>After launching the app I the console is not accepting input anymore and "pry" only comes back accepting input when I close the SimpleFXApplication window.</p>
  
  <p>I've also tried using Java Threads:</p>
  
  <pre><code>...
  binding.pry
  Java.java.lang.Thread.new do SimpleFXApplication.launch end
  </code></pre>
  
  <p>But then, although a new thread id is shown as running, SimpleFXApplication never starts.</p>
  
  <p>Another thing I tried is starting pry from console and then requiring and launching SimpleFXApplication: </p>
  
  <blockquote>
    <p>jruby -S pry</p>
    
    <p>require './jrubyfx_demo.rb'</p>
    
    <p>true</p>
    
    <p>SimpleFXApplication.launch</p>
  </blockquote>
  
  <p>And I receive the following errors...</p>
  
  <blockquote>
    <p>Exception running Application: java.net.MalformedURLException: unknown
    protocol: c java.net.URL.(Unknown Source)
    java.net.URL.(Unknown Source)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source) java.lang.reflect.Constructor.newInstance(Unknown Source)
    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(Native Method)
    com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    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(Unknown Source)
    => nil</p>
  </blockquote>
  
  <p>I am guessing it has something to do in how JrubyFx uses threads, or I don't know if it is a more generic issue that affects Pry usage with JRuby..
  I'd like to know more, I'd appreciate if someone could share some advice.</p>