Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Debugging java class called from Matlab

Subject: Debugging java class called from Matlab

From: Yair Altman

Date: 28 Aug, 2007 15:58:44

Message: 1 of 25

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

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 30 Nov, 2007 21:05:08

Message: 2 of 25

"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!

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 7 Mar, 2008 16:11:02

Message: 3 of 25

I just found out that port 1044 is very popular (used by
many software) which causes MATLAB not to launch if there is
any other process is using the port. So changing it to
something else would be a good idea.

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 16 Apr, 2008 16:19:03

Message: 4 of 25

"Ed Yu" <ekyu88@hotmail.com> wrote in message
<fqrpem$r2s$1@fred.mathworks.com>...
> I just found out that port 1044 is very popular (used by
> many software) which causes MATLAB not to launch if there is
> any other process is using the port. So changing it to
> something else would be a good idea.

Also a good idea to use the follow flag to disable JIT compiler:

-Djava.compiler=NONE

Subject: Debugging java class called from Matlab

From: Aleks

Date: 1 Aug, 2008 15:32:02

Message: 5 of 25

"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)

Subject: Debugging java class called from Matlab

From: siva

Date: 4 Aug, 2008 08:46:46

Message: 6 of 25

Hi,

Please help me in getting the second point mentioned above. I am not able to find the path %MATLAB_ROO%\bin\arch.
Please explain me more....

Thanks in advance

Subject: Debugging java class called from Matlab

From: Kenneth

Date: 16 Sep, 2008 21:49:02

Message: 7 of 25

This seems like a good idea, but it didn't work for me. I believe I followed the instructions, but when I run the launcher in Eclipse, I get a dialog saying:

Failure to connect to remote VM. Connection refused.
Connection refused: connect

This happens whether Matlab is started before the launcher or after.

I made the file java.opts in C:\Program Files\Matlab\2007a\bin\win32.

Possible reasons:

1. I tried putting the opts on one line or on multiple lines as in the forum message. I also tried with and without -Djava.compiler=NONE. (So should it be one line or multiple lines? I can't find any good documentation on java.opts.) This is my current choice:

-Xdebug
-Xrunjdwp:transport=dt_socket,address=5678,server=y,suspend=n
-Djava.compiler=NONE

2. I am using 7.4.0.287 (R2007a). The forum says MATLAB 7R14. (I don't understand this numbering.) Is my version too old?

3. I am using Eclipse 3.3.2.

4. I have tried several different ports. 1044 is not currently in use on my machine, however.

Any help would be appreciated. I've run out of ideas, and I can't find this documented anywhere else.

Thanks.

Subject: Debugging java class called from Matlab

From: Andy Johnson

Date: 25 Sep, 2008 18:31:46

Message: 8 of 25

Try the following in java.opts:
-agentlib:jdwp=transport=dt_socket,address=5678,server=y,suspend=n

The -Xrunjdwp option is deprecated.

-AndyJ

"Kenneth " <nomail@email.com> wrote in message
news:gap9ke$gne$1@fred.mathworks.com...
> This seems like a good idea, but it didn't work for me. I believe I
> followed the instructions, but when I run the launcher in Eclipse, I get a
> dialog saying:
>
> Failure to connect to remote VM. Connection refused.
> Connection refused: connect
>
> This happens whether Matlab is started before the launcher or after.
>
> I made the file java.opts in C:\Program Files\Matlab\2007a\bin\win32.
>
> Possible reasons:
>
> 1. I tried putting the opts on one line or on multiple lines as in the
> forum message. I also tried with and without -Djava.compiler=NONE. (So
> should it be one line or multiple lines? I can't find any good
> documentation on java.opts.) This is my current choice:
>
> -Xdebug
> -Xrunjdwp:transport=dt_socket,address=5678,server=y,suspend=n
> -Djava.compiler=NONE
>
> 2. I am using 7.4.0.287 (R2007a). The forum says MATLAB 7R14. (I don't
> understand this numbering.) Is my version too old?
>
> 3. I am using Eclipse 3.3.2.
>
> 4. I have tried several different ports. 1044 is not currently in use on
> my machine, however.
>
> Any help would be appreciated. I've run out of ideas, and I can't find
> this documented anywhere else.
>
> Thanks.

Subject: Debugging java class called from Matlab

From: Kenneth Evans

Date: 25 Sep, 2008 21:04:01

Message: 9 of 25

Andy,

When I went to try what you suggested, I found the real problem. I had put java.opts in the wrong bin/arch. I do apologize.

It is apparently OK to put the opts on separate lines. This is what I am now using:

-Xdebug
-agentlib:jdwp=transport=dt_socket,address=5678,server=y,suspend=n
-Djava.compiler=NONE

It is truly awesome. Thanks to you and the others for working this out.

     -Ken

Subject: Debugging java class called from Matlab

From: Holger

Date: 13 Oct, 2008 10:08:01

Message: 10 of 25

Hi.

For debugging java classes: Does anybody know if / how it is possible to connect Eclipse 3.2.1 and MATLAB 6.0.0.88 (R12) on Windows ?

Any help would be really appreciated.

BR,
Holger

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 10 Mar, 2009 21:39:01

Message: 11 of 25

"Holger " <hneuhaus@web.de> wrote in message <gcv6m1$b08$1@fred.mathworks.com>...
> Hi.
>
> For debugging java classes: Does anybody know if / how it is possible to connect Eclipse 3.2.1 and MATLAB 6.0.0.88 (R12) on Windows ?
>
> Any help would be really appreciated.
>
> BR,
> Holger

Probably not earlier versions of MATLAB. The actual constraint is the version of Java bundled with the version MATLAB. As long as the JVM (or JRE) is version 1.5.0 and above (which supports remote debugging), this should work fine.

Subject: Debugging java class called from Matlab

From: Subha Fernando

Date: 31 Aug, 2009 08:06:00

Message: 12 of 25

"Andy Johnson" <ajohnson@mathworks.com> wrote in message <gbglel$g7r$1@fred.mathworks.com>...
> Try the following in java.opts:
> -agentlib:jdwp=transport=dt_socket,address=5678,server=y,suspend=n
>
> The -Xrunjdwp option is deprecated.
>
> -AndyJ
>
> "Kenneth " <nomail@email.com> wrote in message
> news:gap9ke$gne$1@fred.mathworks.com...
> > This seems like a good idea, but it didn't work for me. I believe I
> > followed the instructions, but when I run the launcher in Eclipse, I get a
> > dialog saying:
> >
> > Failure to connect to remote VM. Connection refused.
> > Connection refused: connect
> >
> > This happens whether Matlab is started before the launcher or after.
> >
> > I made the file java.opts in C:\Program Files\Matlab\2007a\bin\win32.
> >
> > Possible reasons:
> >
> > 1. I tried putting the opts on one line or on multiple lines as in the
> > forum message. I also tried with and without -Djava.compiler=NONE. (So
> > should it be one line or multiple lines? I can't find any good
> > documentation on java.opts.) This is my current choice:
> >
> > -Xdebug
> > -Xrunjdwp:transport=dt_socket,address=5678,server=y,suspend=n
> > -Djava.compiler=NONE
> >
> > 2. I am using 7.4.0.287 (R2007a). The forum says MATLAB 7R14. (I don't
> > understand this numbering.) Is my version too old?
> >
> > 3. I am using Eclipse 3.3.2.
> >
> > 4. I have tried several different ports. 1044 is not currently in use on
> > my machine, however.
> >
> > Any help would be appreciated. I've run out of ideas, and I can't find
> > this documented anywhere else.
> >
> > Thanks.
>
Does anyone know how to debug java classes in Eclipse through Matlab in Vista 64 bit enviornment?

Subha Fernando

Subject: Debugging java class called from Matlab

From: Holger

Date: 24 Nov, 2009 13:32:23

Message: 13 of 25

"Ed Yu" <ekyu88@hotmail.com> wrote in message <gp6mll$2mi$1@fred.mathworks.com>...
> "Holger " <hneuhaus@web.de> wrote in message <gcv6m1$b08$1@fred.mathworks.com>...
> > Hi.
> >
> > For debugging java classes: Does anybody know if / how it is possible to connect Eclipse 3.2.1 and MATLAB 6.0.0.88 (R12) on Windows ?
> >
> > Any help would be really appreciated.
> >
> > BR,
> > Holger
>
> Probably not earlier versions of MATLAB. The actual constraint is the version of Java bundled with the version MATLAB. As long as the JVM (or JRE) is version 1.5.0 and above (which supports remote debugging), this should work fine.

Hi Ed,

thanks a lot for your help. Appreciated very much.

I understood that I need to update the jvm version in order to use remote java debugging with MATLAB 6.0.0.888 (R12) on Windows. This MATLAB version is shipped with java version 1.1.8.

I've read the related messages in the news group, and set the JAVA_MATLAB env. variable accordingly, etc., but then MATLAB startup fails. I fear that the described solution does not work for MATLAB 6.0.

Does anybody know if MATlAB 6.0 can be upgraded w.r.t. a jvm version larger than 1.1.8 ?

BR, Holger

Subject: Debugging java class called from Matlab

From: Fabio

Date: 19 Jan, 2010 14:17:05

Message: 14 of 25

I'm using Matlab 7.8.0 (R2009)on linux x86_64 and directory %MATLAB_ROOT%\bin\arch doesn't exist ! :-(
where I have to put the java.opts file ?

Thanks


"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!

Subject: Debugging java class called from Matlab

From: Steven Lord

Date: 19 Jan, 2010 14:29:40

Message: 15 of 25


"Fabio " <emanuele.guidolotti@gmail.com> wrote in message
news:hj4et1$t0c$1@fred.mathworks.com...
> I'm using Matlab 7.8.0 (R2009)on linux x86_64 and directory
> %MATLAB_ROOT%\bin\arch doesn't exist ! :-( where I have to put the
> java.opts file ?

When Yair used the word "arch", he intended for you to replace that with the
appropriate directory for your platform -- so because you're using 64-bit
Linux, the directory you're looking for is:

fullfile(matlabroot, 'bin', 'glnxa64')

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 9 Feb, 2010 20:57:02

Message: 16 of 25

I've now upgraded to Vista 64 and the problem is that the MATLAB 2007a launched JVM (1.5.0_05) died whenever I start using either options:

# old way
#-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
# new way
#-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5678

Anyone successfully debug the 64 bit MATLAB (and Java) on Vista 64 or Windows 7 64?

Ed.

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 12 Feb, 2010 20:51:09

Message: 17 of 25

> I've now upgraded to Vista 64 and the problem is that the MATLAB 2007a launched JVM (1.5.0_05) died whenever I start using either options:
>
> # old way
> #-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
> # new way
> #-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5678
>
> Anyone successfully debug the 64 bit MATLAB (and Java) on Vista 64 or Windows 7 64?
>

Found a solution... Since I'm running the MATLAB development environment, I've upgraded to the latest 64 bit JDK matching the MATLAB java version (1.5.0 for 2007a) and MATLAB launched with my java.opts file.

Subject: Debugging java class called from Matlab

From: Donald Frankel

Date: 15 Feb, 2011 21:49:04

Message: 18 of 25

"Andy Johnson" <ajohnson@mathworks.com> wrote in message <gbglel$g7r$1@fred.mathworks.com>...
> Try the following in java.opts:
> -agentlib:jdwp=transport=dt_socket,address=5678,server=y,suspend=n
>
> The -Xrunjdwp option is deprecated.
>
> -AndyJ
>
> "Kenneth " <nomail@email.com> wrote in message
> news:gap9ke$gne$1@fred.mathworks.com...
> > This seems like a good idea, but it didn't work for me. I believe I
> > followed the instructions, but when I run the launcher in Eclipse, I get a
> > dialog saying:
> >
> > Failure to connect to remote VM. Connection refused.
> > Connection refused: connect
> >
> > This happens whether Matlab is started before the launcher or after.
> >
> > I made the file java.opts in C:\Program Files\Matlab\2007a\bin\win32.
> >
> > Possible reasons:
> >
> > 1. I tried putting the opts on one line or on multiple lines as in the
> > forum message. I also tried with and without -Djava.compiler=NONE. (So
> > should it be one line or multiple lines? I can't find any good
> > documentation on java.opts.) This is my current choice:
> >
> > -Xdebug
> > -Xrunjdwp:transport=dt_socket,address=5678,server=y,suspend=n
> > -Djava.compiler=NONE
> >
> > 2. I am using 7.4.0.287 (R2007a). The forum says MATLAB 7R14. (I don't
> > understand this numbering.) Is my version too old?
> >
> > 3. I am using Eclipse 3.3.2.
> >
> > 4. I have tried several different ports. 1044 is not currently in use on
> > my machine, however.
> >
> > Any help would be appreciated. I've run out of ideas, and I can't find
> > this documented anywhere else.
> >
> > Thanks.
>
I have the same problem that Kenneth had, "connection refused". My software versions are:
Matlab 7.11.0.584 (R2010b)
Windows 7 Enterprise
Eclipse IDE for Java Developers 3.6.1. etc.
Java 1.6.0_22

I don't know how to find the version of JDK installed, if that is different from the other version info above.

java.opts is at C:\Program Files\MATLAB\R2010b\bin\win64
Its contents are:
-Xdebug -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -Djava.compiler=NONE

all on one line. (I find that if this is broken into more than one line, Matlab will not launch.) The eclipse debug configuration matches the java.opts socket value. I've tried 5678 also with no greater success.

It is possible that I have a file access permission problem. Since I must use a managed desktop, I don't normally have permission to modify system files, nor install applications. For example, I had to specifically ask the sysadmin to grant me write permission to create java.opts. If that is the problem, I would need to know what permission to ask for.

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 15 Feb, 2011 22:53:03

Message: 19 of 25

Don,

To find out the version of java MATLAB is installed with, use MATLAB command 'ver java'. For some versions of MATLAB 64 bit, they did not bundle the full java that supports the debug feature. But you seems to have a pretty update version of MATLAB. If you can start MATLAB ok, then use 'netstat -anr' to see if the port is used (8000 in your case) by MATLAB.
Then other possibility would be firewall that blocks ports from Eclipse... You need to have privilege to start up Eclipse and connect to port 8000.

Good luck!

Ed.


"Donald Frankel" <dfrankel@ll.mit.edu> wrote in message
> I have the same problem that Kenneth had, "connection refused". My software versions are:
> Matlab 7.11.0.584 (R2010b)
> Windows 7 Enterprise
> Eclipse IDE for Java Developers 3.6.1. etc.
> Java 1.6.0_22
>
> I don't know how to find the version of JDK installed, if that is different from the other version info above.
>
> java.opts is at C:\Program Files\MATLAB\R2010b\bin\win64
> Its contents are:
> -Xdebug -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -Djava.compiler=NONE
>
> all on one line. (I find that if this is broken into more than one line, Matlab will not launch.) The eclipse debug configuration matches the java.opts socket value. I've tried 5678 also with no greater success.
>
> It is possible that I have a file access permission problem. Since I must use a managed desktop, I don't normally have permission to modify system files, nor install applications. For example, I had to specifically ask the sysadmin to grant me write permission to create java.opts. If that is the problem, I would need to know what permission to ask for.

Subject: Debugging java class called from Matlab

From: Yair Altman

Date: 15 Feb, 2011 22:54:04

Message: 20 of 25

Donald, modern Matlab releases don't use the java.opts thingy any more.
Here's a quick how-to for debugging with Eclipse:

1) Create an Eclipse project (you must use JDK 1.5 or above); to include the source code of your Java classes, remember the folder where you put the output classes when you defined your project.
2) Start Matlab with the –jdb command-line startup option (or on pre-R14 Matlab releases, use the java.opts modification that was explained above).
3) In Matlab, add the folder of the output classes from step 1 into Matlab's javaclasspath. You can use either static or dynamic classpath here.
4) In Eclipse, add a “Remote Java Application” debug configuration: Set Connection Type “Standard (Socket Attach)”, Host “localhost”, Port 4444.
5) Now click the “Debug” button to debug the “Remote Java Application” in Eclipse. If Eclipse fails to connect to Matlab, you’ll see an error message; otherwise, you will see no message and will be able to proceed onward.
6) Place a break-point in your Java code within Eclipse.
7) Back in Matlab, instantiate or execute your Java code. You should see the breakpoint popping up in Eclipse when Matlab calls the Java code and reaches the first breakpoint.

BTW, the steps for NetBeans are somewhat different, but not radically.

Yair Altman
http://UndocumentedMatlab.com

Subject: Debugging java class called from Matlab

From: Donald Frankel

Date: 17 Feb, 2011 19:34:04

Message: 21 of 25

"Yair Altman" wrote in message <ijf06c$2dd$1@fred.mathworks.com>...
> Donald, modern Matlab releases don't use the java.opts thingy any more.
> Here's a quick how-to for debugging with Eclipse:
>
> 1) Create an Eclipse project (you must use JDK 1.5 or above); to include the source code of your Java classes, remember the folder where you put the output classes when you defined your project.
> 2) Start Matlab with the –jdb command-line startup option (or on pre-R14 Matlab releases, use the java.opts modification that was explained above).
> 3) In Matlab, add the folder of the output classes from step 1 into Matlab's javaclasspath. You can use either static or dynamic classpath here.
> 4) In Eclipse, add a “Remote Java Application” debug configuration: Set Connection Type “Standard (Socket Attach)”, Host “localhost”, Port 4444.
> 5) Now click the “Debug” button to debug the “Remote Java Application” in Eclipse. If Eclipse fails to connect to Matlab, you’ll see an error message; otherwise, you will see no message and will be able to proceed onward.
> 6) Place a break-point in your Java code within Eclipse.
> 7) Back in Matlab, instantiate or execute your Java code. You should see the breakpoint popping up in Eclipse when Matlab calls the Java code and reaches the first breakpoint.
>
> BTW, the steps for NetBeans are somewhat different, but not radically.
>
> Yair Altman
> http://UndocumentedMatlab.com
Thanks, Yair. Now it works!

Don

Subject: Debugging java class called from Matlab

From: Donald Frankel

Date: 28 Oct, 2011 14:10:16

Message: 22 of 25

"Donald Frankel" <dfrankel@ll.mit.edu> wrote in message <ijjt7c$o5h$1@fred.mathworks.com>...
> "Yair Altman" wrote in message <ijf06c$2dd$1@fred.mathworks.com>...
> > Donald, modern Matlab releases don't use the java.opts thingy any more.
> > Here's a quick how-to for debugging with Eclipse:
> >
> > 1) Create an Eclipse project (you must use JDK 1.5 or above); to include the source code of your Java classes, remember the folder where you put the output classes when you defined your project.
> > 2) Start Matlab with the –jdb command-line startup option (or on pre-R14 Matlab releases, use the java.opts modification that was explained above).
> > 3) In Matlab, add the folder of the output classes from step 1 into Matlab's javaclasspath. You can use either static or dynamic classpath here.
> > 4) In Eclipse, add a “Remote Java Application” debug configuration: Set Connection Type “Standard (Socket Attach)”, Host “localhost”, Port 4444.
> > 5) Now click the “Debug” button to debug the “Remote Java Application” in Eclipse. If Eclipse fails to connect to Matlab, you’ll see an error message; otherwise, you will see no message and will be able to proceed onward.
> > 6) Place a break-point in your Java code within Eclipse.
> > 7) Back in Matlab, instantiate or execute your Java code. You should see the breakpoint popping up in Eclipse when Matlab calls the Java code and reaches the first breakpoint.
> >
> > BTW, the steps for NetBeans are somewhat different, but not radically.
> >
> > Yair Altman
> > http://UndocumentedMatlab.com
> Thanks, Yair. Now it works!
>
> Don

This question is off topic, but I didn't know another way: Can a similar debugging scheme be arranged for debuggng C++ classes? I'd like to stay in linux and eclipse for debugging.
Don

Subject: Debugging java class called from Matlab

From: Uriel

Date: 22 May, 2012 11:28:06

Message: 23 of 25

I am using Eclipse 3.7.0, and I could not follow step 4. I am missing the "connection type" and port field. I found thought the host port. Any help would be appreciated.

Subject: Debugging java class called from Matlab

From: Gmork

Date: 18 Sep, 2012 18:37:47

Message: 24 of 25

Hi, I followed procedure above but I don't understand last point: how can I instantiate or execute the Java code in Matlab?
How can I send output of execution from NetBeans to Matlab?

Thanks

--http://compgroups.net/comp.soft-sys.matlab/debugging-java-class-called-from-matlab/877692

Subject: Debugging java class called from Matlab

From: Ed Yu

Date: 20 Sep, 2012 17:59:12

Message: 25 of 25

Gmork,

In short, you can't do that... You need to instantiate java object from within MATLAB, then within the MATLAB code, call method of the instantiated java object which would then trigger the remote debugging on your IDE and stop at a your break point...

Good luck!

Ed.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us