Filter löschen
Filter löschen

Error in Matlab compiled executable when using Serial()

4 Ansichten (letzte 30 Tage)
Guido
Guido am 19 Jul. 2015
Beantwortet: Alexander Foster am 30 Sep. 2015
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

Antworten (2)

Harsheel
Harsheel am 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 am 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.

Kategorien

Mehr zu Call Java from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by