How to execute java program in MATLAB?

1 回表示 (過去 30 日間)
Sanjay Saxena
Sanjay Saxena 2015 年 1 月 29 日
回答済み: David Young 2015 年 1 月 29 日
Hello,
I am having MATLAB R2011a Version. I want to execute a java program using MATLAB. For this i have created a java program named as "Hello" and after compiling i converted into class file. Than i opened MATLAB set the class path by using edit classpath.txt. But wen i am executing this code using
o = Hello;
javaMethod('main', o);
it returns ??? Undefined function or variable 'Hello'. what to do?

回答 (1 件)

David Young
David Young 2015 年 1 月 29 日
In
o = Hello;
Hello is the name of a variable, as it would be in Java also. (It could also be the name of a function in MATLAB.) When a variable name appears to the right of =, it is evaluated. Since Hello has not been given a value, the attempt to evaluate it fails and you see the error message.
You probably need
o = 'Hello';
The right hand side of this is a string constant, not a variable.

カテゴリ

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