Unable to use Java class in a package - Undefined function or variable 'CartesianCoordinate'.
18 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Yair Altman
2020-3-3
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Java from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!