Filter löschen
Filter löschen

How do i call java class from matlab

4 Ansichten (letzte 30 Tage)
SAMEER ahamed
SAMEER ahamed am 20 Feb. 2014
Kommentiert: SAMEER ahamed am 22 Feb. 2014
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 Kommentar
SAMEER ahamed
SAMEER ahamed am 22 Feb. 2014
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 22 Feb. 2014
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 Kommentare
Image Analyst
Image Analyst am 22 Feb. 2014
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 am 22 Feb. 2014
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Performance and Memory finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by