How do i call java class from matlab

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 comentario

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

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 22 de Feb. de 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 comentarios

SAMEER ahamed
SAMEER ahamed el 22 de Feb. de 2014
Editada: SAMEER ahamed el 22 de Feb. de 2014
Thank's for reply me , sorry i am not understand ,read myVariable data from XML file. Actually i want to insert matrix{1,i} values in XML so I have Import weka.core.XStream Jar (Weka-3.6.0.Jar Fie) in Java Class . Below Matlab Values are insert in java .
if true
% code
method:matrix{1,i}=[22,54,44,65,65,33,12];%1-by-8 matrix.
clear java;
import edu.lipreading.*;
training = TrainingPanel;
javaMethod('recordSample',training,matrix{1,i});
end
Below Java Class Method:
if true
% code
public static void recordSample(List<Integer> points){
recordedSample.getMatrix().add(points);
}
end
Image Analyst
Image Analyst el 22 de Feb. de 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 el 22 de Feb. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 20 de Feb. de 2014

Comentada:

el 22 de Feb. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by