How do I make the Java serial port example in the MATLAB 7.0 (R14) documentation work?

1 visualizzazione (ultimi 30 giorni)
I am working through the "Calling Java from MATLAB" subsection of the External Interfaces section of the documentation. This documentation includes an example on how to use Java to communicate through a serial port: "Example - Communicating Through a Serial Port." However, I receive an error message that a Java class is not found when I try to execute the given code.

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 24 Apr 2023
Modificato: MathWorks Support Team il 24 Apr 2023
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that the documentation example regarding how to communicate through a serial port with Java is incomplete. In order for the code to execute without error, you must first perform the following steps:
1. Download the javax.comm Java class to a local directory. The class can be downloaded from:https://www.oracle.com/java/technologies/java-communications-api.html
The last Windows version of the class (2.0) can be downloaded from here:http://www.java2s.com/Code/Jar/c/Downloadcomm20jar.htm
2. Add the Java class to the Java class path in MATLAB. Type:
edit classpath.txt
For example, if you downloaded the package to $MATLAB7/work/javax, where $MATLAB is your MATLAB root directory, you would add the following entry to classpath.txt:
$matlabroot/work/javax/commapi/comm.jar
3. Copy the win32com.dll file from the commapi directory into $MATLAB\sys\java\jre\win32\jre1.4.2\bin
4. Copy the comm.jar file from the commapi directory into $MATLAB\sys\java\jre\win32\jre1.4.2\lib\ext.
5. Copy the javax.comm.properties file from the commapi directory into $MATLAB7\sys\java\jre\win32\jre1.4.2\lib.
6. Exit MATLAB and restart it. The documentation example should now work.

Più risposte (0)

Categorie

Scopri di più su Java Package Integration in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by