MATLAB as Java IDE

5 ビュー (過去 30 日間)
cyberdyne
cyberdyne 2012 年 9 月 10 日
回答済み: Wolfgang Garn 2014 年 12 月 1 日
Hi,
Is there a way to use MATLAB as Java IDE (like NetBeans, Eclipse, ecc.) ?
How can I find a guide or somewhat for it ?
thanks

回答 (4 件)

Titus Edelhofer
Titus Edelhofer 2012 年 9 月 11 日
Hi Alessandro,
no, not really. Of course you can edit the java files with the MATLAB editor, and compile them calling the java compiler from command window e.g. like
!javac -cp . yourClass.java
but I only do this for very (!) simple java files. Otherwise, that's what eclipse and NetBeans are for ...
Titus

Malcolm Lidierth
Malcolm Lidierth 2012 年 9 月 11 日
It would probably be better to use NetBeans and co. for the development, compiling etc. But you can usefully use MATLAB as an interactive environment for testing the code - start MATLAB with the -jdb option and attach your IDE's profiler to the specified port. Code snippets can also be tested out by running a Java console from the MATLAB command line e.g. the Groovy Console gives you a GUI for loading jars etc.
If you are on a Mac, you can even recompile, clear classes and reload the jars without exiting MATLAB - albeit with some limitations as the method signatures will be get cached.
For details, look at Yair Altman's Undocumented MATLAB blog (and book):
  3 件のコメント
Malcolm Lidierth
Malcolm Lidierth 2012 年 9 月 16 日
Debugging - yes.
cyberdyne
cyberdyne 2012 年 9 月 16 日
編集済み: cyberdyne 2012 年 9 月 16 日
I've found that page; section 1.6. but....on page 31 what means "In Matlab, add the folder of the output classes from step 1 into Matlab’s javaclasspath"? Have I to set an exported .jar file with classes by eclipse?
Also..in the same section at point 7. how can I instantiate or execute java code in matlab?

サインインしてコメントする。


Yair Altman
Yair Altman 2012 年 9 月 11 日
Take a look at MatClipse, a Matlab plugin for Eclipse: http://code.google.com/a/eclipselabs.org/p/matclipse/
  1 件のコメント
cyberdyne
cyberdyne 2012 年 9 月 14 日
MatClipse "imports" matlab into eclipse. I need to use matlab as java ide because I've to use someother toolbox.

サインインしてコメントする。


Wolfgang Garn
Wolfgang Garn 2014 年 12 月 1 日
I have to agree with Titus. However, one could create a very simple IDE. You can add a new shortcut to the quick access toolbar:
Here is some underlying code (far from perfect, but a start):
function javac
% Compiles "simple" java files currently in the Matlab editor to its java classes
% TODO: does not work for packages - use javaclasspath, parse file, consider dependencies
openDocuments = matlab.desktop.editor.getAll;
files = {openDocuments.Filename};
original_folder = pwd;
for filename=files
[pathstr,name,ext] = fileparts(filename{1});
if strcmp(ext,'.java')
cd(pathstr);
dos(['javac ' name ext],'-echo'); % assumes javac is on path
% TODO: find javac automatically, usually in C:\Program Files\Java\jdk1.7.0_45\bin
fprintf(1,'Compiled %s%s\n',name,ext);
javaaddpath(pathstr); % to make changes active in Matlab reload java class path
% TODO: consider static class path as well
end
end
cd(original_folder);
%msgbox('Compiled all current java files to classes','javac');

カテゴリ

Help Center および File ExchangeCall Java from MATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by