The error in your code is not due to the version of JDK, but how, you add use the function JAVAADDPATH. The solution is available here: http://www.mathworks.com/support/solutions/en/data/1-9FSYXW/index.html?product=SL&solution=1-9FSYXW. In general, however, you will need to use the same version of JDK for compilation.
Creating and Using Java Objects
4 次查看(过去 30 天)
显示 更早的评论
Consider the following java function : package mypackage; public class MyClassFunc { private MyClassFunc(){ } public static int val() { reurn 1; } } I have successfully compiled my function with NetBeans then I recovered MyClassFunc.class and MyClassFunc.jar in c:\myclassfunc
in Matlab : javaaddpath(fullfile('c:\myclassfunc','MyClassFunc.jar')); When I used methodsview to view class method, I got this error: ??? Undefined variable "mypackage" or class "mypackage".
is that it is a java version problem ? >> version -java
ans =
Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ Client VM mixed mode
the one I use for compilation jdk1.7.0_25
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Java Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!