Eclipse怎么开发控制台程序并能导出到其他机子上运行?

trycome 2010-02-08 02:44:14
一直做WEB开发,不知道写个控制台运行的程序,放到其他机子上运行,关键是在Eclipse里能运行了,不知道怎么导出来包括一些.jar包(如连接数据库的包),在本地的command上运行会报找到不相应的.jar包?
...全文
354 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
trycome 2010-02-09
  • 打赏
  • 举报
回复
知道错误了,
java.lang.SecurityException: invalid SHA1 signature file digest for com/microsoft/sqlserver/jdbc/CharacterStreamSetterArgs.class


Mircosoft had signed the jar file thru their own tools. So when you try to use the jar file directly or signing by your own tool and using on your JNLP will give this problem.

To solve this problem steps to be followed.

1. Extract the sqljdbc.jar or sqljdbc4.jar file
2. Goto META-INF Folder
3. Open MANIFEST.MF and delete all the lines other than first line and save it
4. Delete other files which exist in the same folder
5. Finally once again make a new jar file including com and META-INF folder as sqljdbc.jar or sqljdbc4.jar

把一些jar包从新打包一下,好像是Mircosoft 的signed

trycome 2010-02-09
  • 打赏
  • 举报
回复
Exception in thread "main" java.lang.SecurityException: invalid SHA1 signature file digest for com/microsoft/sqlserver/jdbc/CharacterStreamSetterArgs.class
这个错误是 defonds 说的需要数字签名的安全认证吗?
i李小武 2010-02-08
  • 打赏
  • 举报
回复
推荐一个好用的eclipse打包工具fatjar google一下就能解决楼主的问题了。
hui135 2010-02-08
  • 打赏
  • 举报
回复
我开发web程序打包成.war包。放到有TOMCAT的服务器上就可以跨平台运行了。
Defonds 2010-02-08
  • 打赏
  • 举报
回复
引用 12 楼 trycome 的回复:
我用Eclipse就可以export到jar file就行了 可是到command下
Java -cp myAPP.jar smsApp.SandSmsTest
报错是
Exception in thread "main" java.lang.SecurityException: invalid SHA1 signature file digest for com/microsoft/sqlserver/jdbc/CharacterStreamSetterArgs.class
        at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:438)
这个证明你打包成功了。但是并不是所有 Eclipse 下能跑的程序,安装 jre 的地方就可以运行它的,比如你进行本地资源操作,那么你打包后的 jar 文件必须通过安全验证才可以运行。
trycome 2010-02-08
  • 打赏
  • 举报
回复
怎么引入Eclipse的控制台插件?
  • 打赏
  • 举报
回复
开发一个控制台插件啊,然后导出插件作为一个产品,然后需要该功能时就直接安装该插件就可以实现了,最简单直接的方法是引入Eclipse的控制台插件.
trycome 2010-02-08
  • 打赏
  • 举报
回复
可是我在Eclipse里 run As --java application 能运行,那是个WEB项目.
trycome 2010-02-08
  • 打赏
  • 举报
回复
我用Eclipse就可以export到jar file就行了 可是到command下
Java -cp myAPP.jar smsApp.SandSmsTest
报错是
Exception in thread "main" java.lang.SecurityException: invalid SHA1 signature file digest for com/microsoft/sqlserver/jdbc/CharacterStreamSetterArgs.class
at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:438)
colin_pxx 2010-02-08
  • 打赏
  • 举报
回复
如果是打jar包的话 Eclipse就可以export到jar file就行了
trycome 2010-02-08
  • 打赏
  • 举报
回复
我把我的需求说一遍,看是不是在说同一个事? 比如我有Eclipse有个Web工程。里面的有class和导入的jar包,现在我不需要作为Web工程大部,不部署在Web服务器上,不用JSp servlet,能把这些class(有main函数)和导入的jar包拿出来作为控制台的上去运行,里面会访问一个webservice ,控制台有若干字符串输出。这个能拿到任何其他机子上去运行。以上的程序要怎么打包出来?要用ANT吗?
Defonds 2010-02-08
  • 打赏
  • 举报
回复
引用 8 楼 trycome 的回复:
你是说把需要的jar包都解压,和自己写的源码放一起 ,在用jar -cvf myApp.jar * 打包,在command里去运行包含main入口的类?
只是让你理解 Java 环境依赖的原理。
trycome 2010-02-08
  • 打赏
  • 举报
回复
你是说把需要的jar包都解压,和自己写的源码放一起 ,在用jar -cvf myApp.jar * 打包,在command里去运行包含main入口的类?
Defonds 2010-02-08
  • 打赏
  • 举报
回复
引用 6 楼 trycome 的回复:
引用 4 楼 defonds 的回复:引用 3 楼 trycome 的回复:用什么打包 ant 或 Jar ?jar CMD 命令行下运行命令 jar 会显示 jar 命令的使用说明
你的意思是把源码和需要导入的jar包, 再用jar命令打成一二个jar包?

去看看这个你就明白了,不要看前面的,你只管看它最后打包依赖类的部分:
一次 applet 客户端打印 jasperreport 报表任务笔记
trycome 2010-02-08
  • 打赏
  • 举报
回复
引用 4 楼 defonds 的回复:
引用 3 楼 trycome 的回复:用什么打包 ant 或 Jar ?jar
CMD 命令行下运行命令
jar

会显示 jar 命令的使用说明

你的意思是把源码和需要导入的jar包, 再用jar命令打成一二个jar包?
trycome 2010-02-08
  • 打赏
  • 举报
回复
可是我有6到7个的包都要一个一个写上吗?main 函数在在自己写的源码文件里,能有 一起吧源码和jar包一起导出的吗 不然我在command里运行不是要输入很多的jar包名称
Defonds 2010-02-08
  • 打赏
  • 举报
回复
引用 3 楼 trycome 的回复:
用什么打包 ant 或 Jar ?
jar
CMD 命令行下运行命令
jar

会显示 jar 命令的使用说明
trycome 2010-02-08
  • 打赏
  • 举报
回复
用什么打包 ant 或 Jar ?
Defonds 2010-02-08
  • 打赏
  • 举报
回复
你把 main 入口类打包就可以了。所有依赖的类都包括了,不需要你手工一起导出。
霜之哀伤 2010-02-08
  • 打赏
  • 举报
回复
cmd运行 要用-cp参数指定classpath,添加那些jar包的路径,这样才能找到。

58,452

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧