在Eclipse中添加外部jar [英] Adding External jar's in Eclipse

查看:120
本文介绍了在Eclipse中添加外部jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个连接到MySQL的程序。我使用eclipse add external jar选项添加Connector / j。节目在日食中工作正常。但是当我使用eclipse创建可执行jar,当我运行它时,它总是给ClassNotFoundException。请告诉我如何将外部罐子添加到我的罐子里。还是有其他错误?请帮助我。

解决方案

最简单的解决方案是将您的项目导出为Runnable Jar文件(右键单击在项目 - >导出...-> Runnable Jar文件),将所有依赖关系放在一个jar文件中。



否则,您将需要包含一个类路径到附加js在manifest.mf文件或命令行中使用-cp选项。

  java -cp。; myjar。 jar; mysql.jar my.package.classname 


I have created a program to connect to MySQL. I add Connector/j using eclipse add external jar option. Program works fine in eclipse. But when I created the executable jar using eclipse and when i run it, it always give ClassNotFoundException. Please tell me how to add external jars to my jar. Or is there any other error? Please can anyone help me.

解决方案

The simplest solution is to export your project as a 'Runnable Jar file' (Right-click on project->Export...->Runnable Jar file) that will place all dependencies in one jar file.

Otherwise you will need to include a classpath to the additional jars either in the manifest.mf file or on the command line with the -cp option.

java -cp .;myjar.jar;mysql.jar my.package.classname

这篇关于在Eclipse中添加外部jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆