MATLAB Answers

Guido
0

Error in Matlab compiled executable when using Serial()

Asked by Guido
on 19 Jul 2015
Latest activity Answered by Alexander Foster on 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

  0 Comments

Sign in to comment.

2 Answers

Answer by 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.

  0 Comments

Sign in to comment.


Answer by 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.

  0 Comments

Sign in to comment.