How to execute java program in MATLAB?

1 vue (au cours des 30 derniers jours)
Sanjay Saxena
Sanjay Saxena le 29 Jan 2015
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?

Réponses (1)

David Young
David Young le 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.

Catégories

En savoir plus sur Call Java from MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by