# How can I debug a JRuby class that is invoked from a Java ap

**URL:** <https://www.ruby-forum.com/t/how-can-i-debug-a-jruby-class-that-is-invoked-from-a-java-ap/113609>\
**Category:** Ruby\
**Created:** [September 2, 2007, 8:50pm UTC](https://www.ruby-forum.com/t/how-can-i-debug-a-jruby-class-that-is-invoked-from-a-java-ap/113609 "2007-09-02T20:50:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3e96dc/32.png) [@luis](https://www.ruby-forum.com/u/luis)\
**Post date:** [September 2, 2007, 8:50pm UTC](https://www.ruby-forum.com/t/how-can-i-debug-a-jruby-class-that-is-invoked-from-a-java-ap/113609/1 "2007-09-02T20:50:51Z")

</div>

I am using JRuby (through the standard JRE 6 support) to add some Ruby  
classes to a big existing Java application.

This application is started as usual as any Java app (by running a  
main method), and it eventually calls my Ruby code. Is there a way to  
debug Ruby code which is being called from Java?

If not, is there any hack/workaround? I know I can unit-test my Ruby  
code but if I want to debug the real (and complex) environment, I need  
to have my Ruby code called from the Java application…

Thanks,

Luis.

---

<div class="post-metadata">

**Author:** ![luis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3e96dc/32.png) [@luis](https://www.ruby-forum.com/u/luis)\
**Post date:** [September 2, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/how-can-i-debug-a-jruby-class-that-is-invoked-from-a-java-ap/113609/2 "2007-09-02T21:32:56Z")

</div>

Luis wrote:

> I am using JRuby (through the standard JRE 6 support) to add some Ruby  
> classes to a big existing Java application.
> 
> This application is started as usual as any Java app (by running a  
> main method), and it eventually calls my Ruby code. Is there a way to  
> debug Ruby code which is being called from Java?
> 
> If not, is there any hack/workaround? I know I can unit-test my Ruby  
> code but if I want to debug the real (and complex) environment, I need  
> to have my Ruby code called from the Java application…

At the moment this is not yet possible. The challenge here is that most  
of the Ruby debugging support out there depends on runtime hooks and  
callbacks that comprise their own debugging framework and API. See the  
debug-commons project on RubyForge for work on standardizing that.

However soon JRuby will be able to compile all Ruby code to Java  
bytecode. You would conceivably then be able to step through Ruby code  
just like Java code using any Java debugging tool, since the compiled  
bytecode would have file and line number information. Taking that a  
couple steps further to support breakpoints and profiling would not be  
hard.

So then, the short answer is that this is not possible right now…but  
it will be possible in the very near future.

- Charlie

---

<div class="post-metadata">

**Author:** ![luis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3e96dc/32.png) [@luis](https://www.ruby-forum.com/u/luis)\
**Post date:** [September 2, 2007, 10:45pm UTC](https://www.ruby-forum.com/t/how-can-i-debug-a-jruby-class-that-is-invoked-from-a-java-ap/113609/3 "2007-09-02T22:45:49Z")

</div>

On Sep 2, 9:31 pm, Charles Oliver N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > to have my Ruby code called from the Java application…  
> > couple steps further to support breakpoints and profiling would not be hard.
> 
> So then, the short answer is that this is not possible right now…but  
> it will be possible in the very near future.
> 
> - Charlie

Charlie, that is great news. Could you give me an approximation of  
when will that feature be available?

Thanks for your quick reply,

Luis.

---

<div class="post-metadata">

**Author:** ![luis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3e96dc/32.png) [@luis](https://www.ruby-forum.com/u/luis)\
**Post date:** [September 2, 2007, 11:32pm UTC](https://www.ruby-forum.com/t/how-can-i-debug-a-jruby-class-that-is-invoked-from-a-java-ap/113609/4 "2007-09-02T23:32:55Z")

</div>

Luis wrote:

> > So then, the short answer is that this is not possible right now…but  
> > it will be possible in the very near future.
> > 
> > - Charlie
> 
> Charlie, that is great news. Could you give me an approximation of  
> when will that feature be available?
> 
> Thanks for your quick reply,

Full compilation to Java is planned for JRuby 1.1, by end of October.  
Probably 95% of Ruby syntax compiles right now.

- Charlie
