How to execute java program in MATLAB?
1 view (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
David Young
on 29 Jan 2015
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.
0 Comments
See Also
Categories
Find more on Call Java from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!