Creating and Using Java Objects

1 次查看(过去 30 天)
Hedi
Hedi 2013-7-25
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

回答(1 个)

Lokesh Ravindranathan
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.

类别

Help CenterFile Exchange 中查找有关 Call Java from MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by