Unable to use Java class in a package - Undefined function or variable 'CartesianCoordinate'.
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi seniors,
I've been using java classes in Matlab for a while. But today, the error "Undefined function or variable 'CartesianCoordinate'." happened when I wanted to use the class called CartesianCoordinate. I've checked what I know e.g., the path and everything is fine. I'm quite confused why this happened. It's hard to understand the problem by text so, please let me explain with some figures.
I've included the following three pathes into the STATIC JAVA PATH:
I have some classes in the folder C:\Users\qw953\SUMO\sumo_files\Demos\Matlabfiles\Java\Lab3Test All the classes in this directory work perfectly. I use them in a simple way in Matlab. For example, m = Lab3Test; Then I'm able to call methods of the specific class.
However, when I want to use the class CartesianCoordinate in geometry folder (geometry is a package), the error happened. I assume the class LineSegment wouldn't work as well. But I have no idea what the reason is since I've already added C:\Users\qw953\SUMO\sumo_files\Demos\Matlabfiles\Java\Lab3Test\geometry into javaclasspath.txt and the corresponding .class files are right there. Is this possibly because classes in Lab3Test imported classes in geometry ?
Then what I did is moving the class CartesianCoordinate to Lab3Test folder, then it can be used as normal. Is it still because the class path related issue is not sorted?
I hope I have made the problem clear enough. Please help me with this and thank you in advance.
0 commentaires
Réponses (1)
Yair Altman
le 3 Mar 2020
This problem could be due to numerous possible causes, and unfortunately Matlab is not very helpful in explaining the root cause. See here: http://undocumentedmatlab.com/articles/java-class-access-pitfalls
Voir également
Catégories
En savoir plus sur Call Java from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!