Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Debugging java class called from Matlab
Date: Fri, 1 Aug 2008 15:32:02 +0000 (UTC)
Organization: Simrad AS
Lines: 62
Message-ID: <g6va9i$6r7$1@fred.mathworks.com>
References: <fb1gnk$5o4$1@fred.mathworks.com> <fiptu4$l3b$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 1217604722 7015 172.30.248.37 (1 Aug 2008 15:32:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 1 Aug 2008 15:32:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1411056
Xref: news.mathworks.com comp.soft-sys.matlab:483120



"Ed Yu" <ekyu88@hotmail.com> wrote in message <fiptu4
$l3b$1@fred.mathworks.com>...
> "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!

Works quite well, thanks! Also, helps to remember to 
compile with -g flag as usual, to generate the debugging 
info. (javac -g YourBuggyCode.java)