java 串口程序打包
以前打包都没问题 但这个 有点特殊我刚刚 用 Eclipse 3.2 写了 个 java 的 串口通讯程序,现在程序写完了,在Eclipse 下 运行 没有问题
用控制台命令运行也没有问题。但是 我 打成 jar 包 运行 却 出现了 问题,双击 my.jar 程序的界面 可以运行,但是串口发送信息不能用。
这是 我 打包的mf 文件
Manifest-Version: 1.0
Main-Class: mypackage.Test
Class-Path: comm.jar
Created-By: 1.5.0_08 (Sun Microsystems Inc.)
我想了 下 我 的 程序引用了两个 外部的文件 comm.jar 和 win32com.dll
另外 我 的 写 串口程序还重新配置了下 jdk 我按照如下步骤改动配置
Installing the Java Communications API on JDK 1.2 (RC1)
<jdk> refers to the root directory of your JDK installation. If you installed JDK in c:\\jdk1.2 then replace all reference to <jdk> with c:\\jdk1.2.
1.
Windows: place the win32com.dll in <jdk>\\jre\\bin directory.
2.
Place the comm.jar in <jdk>\\jre\\lib\\ext.
3.
Place the javax.comm.properties in <jdk>\\jre\\lib .
4.
Do not alter the CLASSPATH.
我 在网上试了很多方法都没有成功
我猜想 是不是 win32com.dll和 javax.comm.properties 的 问题,java 写这种程序好麻烦,怎么 打成jar 包 是我的第一步,我想吧这个搞好后
再想着 怎么 吧这个jre 给 打进去 让他 变成 exe 在 其他 没有装 java运行环境的 地方直接 双击就能运行望抽出点时间看下,也希望大家帮帮忙。
以前打包都没问题 但这个 有点特殊我刚刚 用 Eclipse 3.2 写了 个 java 的 串口通讯程序,现在程序写完了,在Eclipse 下 运行 没有问题
用控制台命令运行也没有问题。但是 我 打成 jar 包 运行 却 出现了 问题,双击 my.jar 程序的界面 可以运行,但是串口发送信息不能用。
这是 我 打包的mf 文件
Manifest-Version: 1.0
Main-Class: mypackage.Test
Class-Path: comm.jar
Created-By: 1.5.0_08 (Sun Microsystems Inc.)
我想了 下 我 的 程序引用了两个 外部的文件 comm.jar 和 win32com.dll
另外 我 的 写 串口程序还重新配置了下 jdk 我按照如下步骤改动配置
Installing the Java Communications API on JDK 1.2 (RC1)
<jdk> refers to the root directory of your JDK installation. If you installed JDK in c:\\jdk1.2 then replace all reference to <jdk> with c:\\jdk1.2.
1.
Windows: place the win32com.dll in <jdk>\\jre\\bin directory.
2.
Place the comm.jar in <jdk>\\jre\\lib\\ext.
3.
Place the javax.comm.properties in <jdk>\\jre\\lib .
4.
Do not alter the CLASSPATH.
我 在网上试了很多方法都没有成功
我猜想 是不是 win32com.dll和 javax.comm.properties 的 问题,java 写这种程序好麻烦,怎么 打成jar 包 是我的第一步,我想吧这个搞好后
再想着 怎么 吧这个jre 给 打进去 让他 变成 exe 在 其他 没有装 java运行环境的 地方直接 双击就能运行望抽出点时间看下,也希望大家帮帮忙。
你必须做到如下几点
1,把win32com.dll放到你的PATH目录下,比如C:\WINDOWS\system32下面
2,把javax.comm.properties放到你的JRE\lib目录下,缺一不可.否则就没有办法了
你如果想把JRE一起加包进去也是可以的,你可以用install4j把JRE一起打进去,并且在安装的时候,就可以
把win32com.dll复制到系统目录下.然后安装完后就可以马上运行,而不用手动复制了.
将Class-PAth修改为Class-Path: lib/comm.jar
把win32com.dll直接放到my.jar里java -jar my.jar的命令后加上参数 -Djava.library.path=.
javax.comm.properties放到JRE\lib目录下
我现在打的 这个jre包还是只能 出界面 不能发送信息啊。但是 我写的批处理脚本可以正常运行程序啊是不是 我打包的 哪个步骤出现了问题。麻烦哪位能不能 把打这种包的步骤详细的写一下了。真是有点急,老板还催着呢。
运行 一切 正常,发送信息也正常
但是 双击运行就是不行。
这就说明你的jar包是正确的,你再用右键指定java(TM) Platform SE binary打开试试,
如果这样可以的话,那就是你系统的问题了。
如果打不开,就像Squall1009 说的win32com.dll没有注册,你把它注册一下试试
<jdk> refers to the root directory of your JDK installation. If you installed JDK in c:\\jdk1.2 then replace all reference to <jdk> with c:\\jdk1.2.
1.
Windows: place the win32com.dll in <jdk>\\jre\\bin directory.
2.
Place the comm.jar in <jdk>\\jre\\lib\\ext.
3.
Place the javax.comm.properties in <jdk>\\jre\\lib .
4.
Do not alter the CLASSPATH. 上述配置是应用于代码开发的,要是运行jar要用到<jre>目录下的相关文件,把上述配置的<jdk>路径改成你的<jre>路径就可以了~~我刚刚改完,就可以了~~
java.lang.NoClassDefFoundError: javax/comm/SerialPortEventListener
在eclipse下运行没问题。拜托大家能帮帮忙啊
这个怎么解决呢?