[英]How to include an external library into your project properly
I am using the Keyczar Java library to encrpyt and decrpyt information. 我正在使用Keyczar Java库来加密和解密信息。
I am trying to do the below as stated on the main site 我正在尝试按照主站点上的说明进行以下操作
package testing2;
import testing2.org.keyczar;
public class Testing2
{
public static void main(String[] args)
{
Crypter crypter = new Crypter("/path/to/your/keys");
}
}
The compiler gives the following error : Crypter symbol cant be found 编译器给出以下错误: 找不到密码符号
I suspect that the cause of the problem is that I did not include my external library files properly 我怀疑问题的原因是我没有正确包含我的外部库文件
This is how i have included my files 这就是我包括我的文件的方式
What am i doing wrong ??? 我究竟做错了什么 ???
To include external library/ JARs into your project follow following steps: 要将外部库/ JAR包含到您的项目中,请执行以下步骤:
Libraries
tab and click Add External JARs
-> Select the library/ JARs you want to include. Libraries
选项卡,然后单击Add External JARs
>选择要包括的库/ JAR。 As shown in below image: Also if you are exporting your project as an Executable JAR
, then go to Order and Export
and select the JAR(s) that you want to included in your executable jar, as shown in below image. 另外,如果要将项目导出为
Executable JAR
,则转到Order and Export
,然后选择要包含在可执行jar中的JAR,如下图所示。
Also in your above code I can see that there is no import statement for Crypter
class. 同样在上面的代码中,我可以看到
Crypter
类没有import语句。 If you have added external JARs by following above procedure, then you can press Ctrl + Shift + O
to solve import problems in Eclipse. 如果按照上述步骤添加了外部JAR,则可以按
Ctrl + Shift + O
解决Eclipse中的导入问题。
I would suggest you to use Maven: http://maven.apache.org/ 我建议您使用Maven: http : //maven.apache.org/
It is most recommended and most widely used software management tool. 它是最推荐和使用最广泛的软件管理工具。 It can manage project build and dependencies pretty easily.
它可以非常轻松地管理项目构建和依赖关系。 Most of the production level application in the current scenario use Maven.
当前方案中的大多数生产级应用程序都使用Maven。
You also do not need to worry about the dependencies of your project, which really helps when your application has heavy external dependencies. 您也不必担心项目的依赖关系,这在您的应用程序具有大量外部依赖关系时确实有帮助。 The project will download the dependencies direct from the maven repository and you won't have to carry them with the project.
该项目将直接从Maven存储库中下载依赖项,而您不必随项目一起携带它们。
If you just want to test out your application you can add a library through your IDE, and it seems like you are using NetBeans check here to see how to do so. 如果您只想测试您的应用程序,则可以通过IDE添加一个库,并且好像您正在使用NetBeans一样,请在此处查看如何进行操作。
As per long term project maintainability and sustainability it's good if you use a project management tool like Maven or Ant 从长期的项目可维护性和可持续性来看,如果您使用诸如Maven或Ant之类的项目管理工具,那将是一件好事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.