How do I make the Java serial port example in the MATLAB 7.0 (R14) documentation work?
1 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2009-6-27
编辑: MathWorks Support Team
2023-4-24
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.
采纳的回答
MathWorks Support Team
2023-4-24
编辑:MathWorks Support Team
2023-4-24
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Java Package Integration 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!