Error in Matlab compiled executable when using Serial()

1 view (last 30 days)
Hi all,
I created a Matlab executable (created with GUIDE) to communicate with an Arduino. Runs fine when started from Matlab environment. But when compiled and installed, it gives an error when using Serial():
"Error using serial (line 85) Cannot create: No class com.mathworks.toolbox.instrument.SerialComm can be located on the Java Class Path"
Does anybody know how to avoid this error?
Some additional comments:
  • 'Run as an administrator' makes no difference
  • Compiled and run with the same (latest) Matlab runtime.
Thanks in advance,
Guido Kooijman

Answers (2)

Harsheel
Harsheel on 20 Jul 2015
It seems like the correct jar files have not been picked up during the compilation process leading to a java runtime error. To resolve this
- Create a javaclasspath.txt file in your preference directory.
Location of prefdir:
>> prefdir %if on windows, just execute >>winopen(prefdir)
- Add the following 2 entries in javaclasspath.txt:
$matlabroot/java/jar/toolbox/testmeas.jar
$matlabroot/java/jar/toolbox/instrument.jar
where $matlabroot should be substituted with your matlab root directory. You can find this by typing:
>> matlabroot
- Restart MATLAB (if open) and recompile your application.

Alexander Foster
Alexander Foster on 30 Sep 2015
I have run into the same issue. I had a program which would compile and run in R2013b but when I upgraded to R2015a and recompiled it I would see, "No class com.mathworks.toolbox.instrument.SerialComm can be located on the Java Class Path".
I fixed the problem by adding the following option to my call to mcc:
-a [matlabroot]\java\jar\toolbox
where [matlabroot] is the path returned when you run the command "matlabroot".
If you use the gui to compile I believe that you can get the same effect using the "File required for your application to run" section.

Categories

Find more on Java Package Integration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!