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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 20:23:46  来源:igfitidea点击:

How to import javax.comm API to Netbeans IDE?

javalinuxnetbeanside

提问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.jarthe 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
  • 导航 到文件所在的文件夹。

enter image description here

在此处输入图片说明

  • open the project -> Properties
  • select Libraries
  • click Add Library ...
  • select the just created comm-linux_all-2.0.0Library
  • 打开项目 -> 属性
  • 选择 Libraries
  • 点击 Add Library ...
  • 选择刚刚创建的comm-linux_all-2.0.0

enter image description here

在此处输入图片说明



  • copy librxtxSerial.soand librxtxParallel.soto /usr/binfolder.
  • 复制librxtxSerial.solibrxtxParallel.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>