配置:
操作系统:WIndows 7-64
java -version: java version "1.7.0_45"
串口通信第三方库RXTX:
RXTXcomm.jar
rxtxSerial.dll
rxtxParallel.dll
要放置的位置:
Java\jre7\lib\ext
RXTXcomm.jar
Java\jdk1.7.0_45\jre\lib\ext RXTXcomm.jar
Java\jre7\bin rxtxSerial.dllrxtxParallel.dll
我这里是缺一都会有问题:
1.缺 Java\jre7\lib\extRXTXcomm.jar
java.lang.NoClassDefFoundError: gnu/io/SerialPortEventListener
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: gnu.io.SerialPortEventListener
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
Exception in thread "main"
并且原来的.class不能运行
2. 缺 Java\jdk1.7.0_45\jre\lib\ext RXTXcomm.jar
port.java:30: 错误: 程序包gnu.io不存在
import gnu.io.*;
^
port.java:61: 错误: 找不到符号
private SerialPort selectPort;
^
符号: 类 SerialPort
位置: 类 port
......
但是原来的.class可以运行
如上都是notepad++
NPP_EXEC: "java"
NPP_SAVE: D:\Code\java\Port\src\port.java
javac port.java
Process started >>>
<<< Process finished. (Exit code 0)
java port
Process started >>>
的结果
并且让程序执行如下这段:
String arch = System.getProperty("sun.arch.data.model");
System.out.println(arch);
打印的结果是32
则jdk应该是32位的
Eclipse貌似自带的都是64位JDK?
在Eclipse下无法运行。
待续...