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

5 次查看(过去 30 天)
(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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Call Java from MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by