在哪里放外部罐子? [英] Where to put the external jars?

查看:154
本文介绍了在哪里放外部罐子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Eclipse(3.4)和我的类编译没有警告或错误。
我的项目使用一个外部jar文件。



我需要将这个外部jar文件放在哪里才能得到一个 java .lang.NoClassDefFoundError 当从另一个项目(不在Eclipse中)使用这个类时?



我可以将jar提取到项目文件夹中,但是这并不是正确的。



编辑:这个问题不是在Eclipse中导入jar,而是在Eclipse之外使用它们。

解决方案

如果您想要将一个JAR文件包含在Eclipse项目中,通常会在项目文件夹内创建一个lib文件夹,并将文件放入那里。然后,您需要告诉eclipse将其包含在您的类路径中,以便您的代码将在eclipse中编译和运行。


要做到这一点:

- 进入项目的属性
- 在左边选择'Java Build Path'手指列$ $ $
- 选择窗口中央部分的库选项卡
- 单击添加JAR按钮 - 这将给您一个在Eclipse中的项目列表 - 扩展您的项目并进入lib文件夹 - 您的jar将在那里。

- 选择JAR,再次点击OK,然后再返回属性窗口。



您的代码现在将编译并运行。


I use Eclipse (3.4) and my class compiles without warning or errors. My project uses an external jar file.

Where do I need to put this external jar file in order not to get a java.lang.NoClassDefFoundError when using this class from another project (not in Eclipse)?

I could just extract the jar into the project folder, but that does not feel right.

Edit: this question is not about importing jars in Eclipse, but using them outside of Eclipse.

解决方案

If you're wanting to include a JAR file to your Eclipse project, you would generally create a 'lib' folder inside the project folder, and put the file in there. You then need to tell eclipse to include it in your class path so your code will compile and run inside eclipse.

To do that:
- Go into the properties of your project
- Select 'Java Build Path' in the left hand column
- Select the 'Libraries' tab in the centre part of the window
- Click the Add JARs button - this will give you a list of your projects in eclipse - expand your project and into the lib folder - your jar will be there.
- Select the JAR, click OK, and OK again out of the properties window.

Your code will now compile and run.

这篇关于在哪里放外部罐子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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