Creating and Using Java Objects

8 vues (au cours des 30 derniers jours)
Hedi
Hedi le 25 Juil 2013
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

Réponses (1)

Lokesh Ravindranathan
Lokesh Ravindranathan le 25 Juil 2013
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.

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!

Translated by