Issue
I'm trying to call a java class from matlab(2010a) but isn't working. I tried to follow this tutorial, but didn't work.
public class Helloworld {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println( "Hello World!" );
}
1)I created this class at netbeans and compiled it using Java 1.6.0_12 (the same that is used at matlab 2010a). 2)I added the generate jar file at dynamic class path, using this command
javaaddpath('C:\Users\xx\Documents\NetBeansProjects\Helloworld\dist\Helloworld.jar');
3) I used this command, to create a object
o = HelloWorld
4)But matlab shows me this message
??? Undefined function or variable 'HelloWorld'.
Any idea about how to solve my issue?
Solution
I was missing the package and I hadn`t send the (empty)argument to the main function.
My full code:
javaaddpath('C:\Users\xx\Documents\NetBeansProjects\Helloworld\dist\Helloworld.jar');
%call class, inclugind the package!
% o = helloworld.Helloworld;
o = helloworld.Helloworld();
%call java method, including the argument
javaMethod('main', o,[]);
Answered By - Rodrigo PG
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.