简体   繁体   中英

How to execute a simple Java Program through MATLAB?

I have written a simple java code on Notepad

public class Hello

{

    public static void main(String[] args)

    {

       System.out.println("Hello");

    }

}

I have compiled this using CMD and convert it into class file. I opened MATLAB command window and opened edit classpath.txt and put the complete path of Hello.class file and restarted MATLAB. I just want to know that now how will I execute this simple java program through MATLAB? am I doing write or wrong?

Thanks in advance!!!

After you restart MATLAB, you have to create a class object and then execute it.

Create a class of HelloWorld

hw = HelloWorld

Then execute it.

javaMethod('main', hw, '')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM