简体   繁体   English

在Matlab中调用Java类的问题

[英]Problems with calling a java class in matlab

I am facing a problem when I try to call a java class in MATLAB. 当我尝试在MATLAB中调用Java类时遇到问题。 I created a java class, I compiled it as .jar file in Netbeans 7.3.1. 我创建了一个Java类,并在Netbeans 7.3.1中将其编译为.jar文件。 When I use the normal procedure to add the path of the .jar file with javaaddpath() and after that to import the class with import I can not access the class. 当我使用常规过程通过javaaddpath()添加.jar文件的路径,然后通过import导入类时,我无法访问该类。 It says no such class or function was found. 它说没有找到这样的类或函数。

This happens just with the class I created but not with other classes that were compiled by others. 这仅在我创建的类中发生,而在其他人编译的其他类中则没有。 I can execute the jar file with system('java -jar jarfile.jar') in MATLAB. 我可以在MATLAB中使用system('java -jar jarfile.jar')执行jar文件。 So it seems that the problem is within matlab and not with java code. 因此,似乎问题出在matlab中,而不是Java代码。

I use MATLAB R2013a and JAVA 1.7. 我使用MATLAB R2013a和JAVA 1.7。

Is there a problem with version compatibility or what!? 版本兼容性有问题吗?或什么!

Matlab 2013a ships with java 1.6 (check ver ). Matlab 2013a随附了Java 1.6(请检查ver )。

You'll either have to compile your class with java 1.6 as well or make MATLAB run with java 1.7: http://www.mathworks.de/support/solutions/en/data/1-1812J/ 您要么必须使用Java 1.6来编译您的类,要么使MATLAB可以使用Java 1.7来运行: http : //www.mathworks.de/support/solutions/en/data/1-1812J/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM