How do i call java class from matlab

2 次查看(过去 30 天)
Hi,
I have java class which is implement in Eclipse IDE , but i want to integrate class in matlab ?Below sample java code ?
if true
% code
import edu.lipreading.*;
public class Student{
public Static Void Main(String[] args){
System.out.println("Welcome to Student Class");
}
}
end
Now Below My Matlab I have tried like Undefined function or variable 'Student'. , but i cannot get result .
if true
% code
javaaddpath('D:\work\Student.jar','-end');
clear java;
import edu.lipreading.*;
o = Student;
javaMethod('main', o);
end
Note : I have tested my Java Version 1.6 jre file download and Environment Path System Variable Path Set Matlab_JAVA , C:/Prog/java/jre1.6/jre;
  1 个评论
SAMEER ahamed
SAMEER ahamed 2014-2-22
Hi,
I have called Java Class from Matlab . now i want to pass this values in Java Class How i can pass this values ?
My Java Class Below :
if true
% code
public static void recordSample(List<Integer> points){
Sample recordedSample = new Sample //Sample Class Getter and Setter Method
//private List<List<Integer>> matrix; Getter and Setter Method
recordedSample.getMatrix().add(points);
}
end
Now I have called this Method from Matlab Below :
if true
% code
for int i=1:20
if true
% code
matrix{1,i}=[22,33,43,12,43,565,54];
end
end
clear java;
import edu.lipreading.*; %Java Class Package
training = TrainingPanel; %Jar Class File
javaMethod('recordSample',training,matrix);
end

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2014-2-22
Here's another example.
% Read in the test's XML file which has all the test parameters.
XMLFullFileName = 'D:/TestData/Test_1234.xml'
javaclasspath('C:/Program Files/MATLAB/Apache Commons/commons-configuration-1.6/commons-configuration-1.6.jar');
conf = org.apache.commons.configuration.XMLConfiguration(XMLFullFileName);
% Extract the string stored in the node "myVariable" from the XML file.
myVariable = conf.getString('TestInfoTopLevel.myVariable')
  3 个评论
Image Analyst
Image Analyst 2014-2-22
That was just an example from my code - one where I wanted to read an XML file. Of course you'll have different java calls that I used.
SAMEER ahamed
SAMEER ahamed 2014-2-22
ok. Thank's for reply me . I'm new for Matlab . I want to pass matrxi{1,i}=[33,2,2,4,2,1,5,76]1-by-8 matrix from matlab to java class method ? please let me know if you are know ?Thanks

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Java Client Programming 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by