Importing Java classes from the Matlab's -r argument it's not working

1 vue (au cours des 30 derniers jours)
Antonio S. Cofiño
Antonio S. Cofiño le 6 Mai 2012
(Matlab version is 7.8.0.347 (R2009a) for windows and linux)
I'm experiencing problems with Java classes name resolution. I have been able to dig into problem and isolate the essence of it.
If I'm running this command from the OS command shell:
matlab -r "str=java.lang.String('Hello')"
it works perfectly. But running this very similar code
matlab -r "import java.lang.String;str=String('Hello')"
I'm getting this Matlab's error:
??? Undefined function or method 'String' for input arguments of type 'char'.
putting the code inside a function,
function dumfunc()
import java.lang.String;
str=String('Hello')
and calling it like this form the OS command shell:
matlab -r "dumfunc"
works perfectly. It doesn't work if a write the code lines into a script it must be a function.
It appears as problem with the name resolution of Java classes and more precissly with the import facility.
Any guess what is going on?
Regards
Antonio

Réponses (0)

Catégories

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

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by