Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Debugging java class called from Matlab
Date: Fri, 30 Nov 2007 21:05:08 +0000 (UTC)
Organization: EGI University of Utah
Lines: 47
Message-ID: <fiptu4$l3b$1@fred.mathworks.com>
References: <fb1gnk$5o4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1196456708 21611 172.30.248.37 (30 Nov 2007 21:05:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 30 Nov 2007 21:05:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 629719
Xref: news.mathworks.com comp.soft-sys.matlab:440278



"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<fb1gnk$5o4$1@fred.mathworks.com>...
> Hello all,
> 
> I wish to debug a Java class that I call from Matlab. Is
> there any way to connect Eclipse (or something else) to set
> debuggable breakpoints in my Java code?
> 
> (simple system.out.println works of course, but I need a
> more heavy-duty debugger)
> 
> Thanks,
> Yair Altman

Hi Yair,

I just figured out how to do it for MATLAB 7R14 (should work
for later versions) and Eclipse (I'm using JBuilder 2007,
which is Eclipse 3.2.2). Here is how:

1) Create a Eclipse project (you must use JDK 1.5 or above)
to include the source code of your java classes, remember
the directory where you put the output classes when you
define your project.

2) Add the following flags in java.opts in directory
%MATLAB_ROO%\bin\arch.

-Xdebug
-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n

3) In your eclipse project, define a debug configuration.
For me, I've to add a "Remote Java Application"
configuration. In the "Connection Type" field, use "Standard
(Socket Attach)". Then use "localhost" for field "Host" and
"1044" for "Port".

4) Then launch MATLAB, make sure you add the directory of
the output classes from step 1 into MATLAB's javaclasspath.
You can use either static or dynamic classpath here.

5) Then debug the "Remote Java Application" on the Eclipse
side, put a break point in your java code and instantiate or
execute your java code from within MATLAB. You should see
the breakpoint popping up when MATLAB calls java.

Have fun!