Error in Matlab compiled executable when using Serial()

1 visualización (últimos 30 días)
Guido
Guido el 19 de Jul. de 2015
Respondida: Alexander Foster el 30 de Sept. de 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

Respuestas (2)

Harsheel
Harsheel el 20 de Jul. de 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 el 30 de Sept. de 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.

Categorías

Más información sobre Java Package Integration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by