Is it possible to create a subclass in Matlab using a superclass written in Java?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ClaireG
el 29 de Mzo. de 2016
Respondida: Adithya Addanki
el 31 de Mzo. de 2016
Hi,
I am quite new to object oriented programming, so hopefully I manage to explain my issue in a clear way.
I have a bunch of classes written in Java that I imported and used successfully in Matlab.
What I haven't been able to do however, is use a java interface as a Matlab superclass.
When I create a new class using:
classdef mySubclass < javaInterface
(methods and properties of the class)
end
I get the error message:
Error using mySubclass
The specified superclass 'javaInterface' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.
I checked that the Interface java class was imported properly by typing methods('javaInterface').
When I looked around in the literature for similar issues, I couldn't find anything relevant to my case.
Do you know if it's even possible to use a java interface as a Matlab Superclass?
Thank you so much for your time, and I apologize in advance if this is a basic question.
Claire
0 comentarios
Respuesta aceptada
Adithya Addanki
el 31 de Mzo. de 2016
Hi Claire,
As the error message suggests, it is searching for a MATLAB class in the search path and is not able to find one.
You will not be able to subclass a Java class in a MATLAB class hierarchy. However, you will be able to use the Java classes in MATLAB by adding them to the javaclasspath (static/ dynamic and importing the required components).
Hope this helps.
- Adithya
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Java Package Integration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!