java 如何将 javax.comm API 导入 Netbeans IDE?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32558898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to import javax.comm API to Netbeans IDE?
提问by JOSHY T R
I am writing a program to read and write from and to serial port of a system using Java in Netbeans IDE. I am working with Ubuntu 14.04 operating system. Actually I am a beginner in java programming. I have downloaded comm-linux_all-2.0.0.jar from oracle's home site and it is copied to workspace directory.
我正在编写一个程序来读取和写入在 Netbeans IDE 中使用 Java 的系统的串行端口。我正在使用 Ubuntu 14.04 操作系统。其实我是java编程的初学者。我已经从 oracle 的主页下载了 comm-linux_all-2.0.0.jar 并将其复制到工作区目录。
After all these things I imported the API using the command
在所有这些事情之后,我使用命令导入了 API
import javax.comm.*;
But it shows the error "Package javax.comm does not exit."
但它显示错误“包 javax.comm 不退出。”
What would be the problem, please help me to resolve the problem.
会是什么问题,请帮我解决问题。
回答by moskito-x
extract comm-linux_all-2.0.0.jar
the files
提取comm-linux_all-2.0.0.jar
文件
somewhere in the NetBeans directory.
NetBeans 目录中的某个位置。
Here we take the following directory. (you know the path on ubuntu)
这里我们取以下目录。(你知道ubuntu上的路径)
\NetBeans80\extra\modules
\NetBeans80\extra\modules
RXTXcomm.jar
comm.jar
RXTXcomm.jar
comm.jar
Now open Netbeans : tools -> libraries
现在开放 Netbeans : tools -> libraries
- create a new lbrary
here : comm-linux_all-2.0.0
- click
Add JAR/Folder
- nav. to the folder where the files are.
- 创建一个新的图书馆
here : comm-linux_all-2.0.0
- 点击
Add JAR/Folder
- 导航 到文件所在的文件夹。
- open the project -> Properties
- select
Libraries
- click
Add Library ...
- select the just created
comm-linux_all-2.0.0
Library
- 打开项目 -> 属性
- 选择
Libraries
- 点击
Add Library ...
- 选择刚刚创建的
comm-linux_all-2.0.0
库
- copy
librxtxSerial.so
andlibrxtxParallel.so
to/usr/bin
folder.
- 复制
librxtxSerial.so
和librxtxParallel.so
对/usr/bin
文件夹中。
now you can use.
现在你可以使用了。
import javax.comm.*;
....
public class JustaClass {
....
回答by Kan
You can check the pom.xml file.
I had the same problem (I am a rookie)
I didn't add the dependencies :
您可以检查 pom.xml 文件。
我有同样的问题(我是菜鸟)
我没有添加依赖项:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>