MATLAB runtime javaclass not found

I have a MATLAB script where I open a serial port like this:

hnd = serial(obj.portName,'Baudrate',57600);

      

This works great when run from the MATLAB command line.

However, if I compile the script, then I come across the following error message:

Serial number error (line 120) Unable to create: The com.mathworks.toolbox.instrument.SerialComm class may be located in the Java classpath.

Any ideas how to fix this problem? I have verified that the port name (COM15) is correct.

+3


source to share


1 answer


When run from MATLAB, the .jar libraries (which are included in your Java classpath in MATLAB) can be used. However, they may not be present when compiled.

If you are using the MATLAB compiler to create a compiled script, there is an Add Additional Files section (or something similar) that will add the .jar as well as any other dependencies.

Try the following:



1) Enter "javaclasspath" from the MATLAB command line to display the location of the .jar libraries.

2) Find the required (this may be the hardest part!)

3) When compiling, be sure to include this file (s).

0


source







All Articles