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

1 view (last 30 days)
Antonio S. Cofiño
Antonio S. Cofiño on 6 May 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

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by