Can I use MATLAB object-oriented class syntax to add methods to a Java class in MATLAB 7.3(R2006b)?

In MATLAB 7.2 (R2006a) I was able to add additional methods to Java classes by creating a MATLAB class directory (@<classname>) and defining functions. This no longer appears to work in R2006b.
For example: I wish to add a 'build' method to the native Java class 'java.util.Hashtable'. In a base directory, I create an '@java.util.Hashtable' directory, and inside it I put a 'build.m' function. Working in the base directory, I create an object of class 'java.util.Hashtable', and then attempt to invoke the 'build' method of that object. This worked in R2006a, but in R2006b returns the error:
??? Undefined function or method 'build' for input arguments of type 'java.util.Hashtable'.
I would like to have MATLAB revert to the older behavior, as this was a very useful tool in working between Java and MATLAB.

 채택된 답변

The ability to use MATLAB object-oriented class syntax to add methods to a Java class is not available in MATLAB 7.3 (R2006b).
To work around this issue, you can create a new Java class that inherits from and extends the base class. Then create an object that is an instance of the extended class.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기

제품

릴리스

R2006b

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by