简体   繁体   English

如何将外部库正确包含到您的项目中

[英]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 ??? 我究竟做错了什么 ???

Download Keyczar from here 从这里下载 Keyczar

To include external library/ JARs into your project follow following steps: 要将外部库/ JAR包含到您的项目中,请执行以下步骤:

  • Right click on project -> Build path -> Configure build path 右键单击项目->构建路径->配置构建路径
  • Go to 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 从长期的项目可维护性和可持续性来看,如果您使用诸如MavenAnt之类的项目管理工具,那将是一件好事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Eclipse中将Maven构建的库包含到您的项目中? - How to include maven built library into your project in eclipse? 如何在导出项目归档文件中包含外部库 - how could I include external library in my export project archive 如何在Eclipse项目(Java)中永久包含外部库? 这样,当将其移植到另一台计算机时,它仍然存在 - How to permanently include an external library in an Eclipse project (Java)? So that when porting it to another computer, it's still there 如何在 CircleCI 上为 Maven 包含外部库 - How to include external library for maven on CircleCI 如何在不复制/移动/编辑的情况下将外部非Android Eclipse库项目包含到Android-Studio项目中? - How to include an external non-Android Eclipse library project into a Android-Studio project without copying/moving/editing? 如何在GWT项目中包含外部软件包? - How to include External packages in a GWT project? 如何将外部jar依赖项包含到Maven项目中? - How to include external jar dependency to maven project? 如何在Android项目中正确包含HTML? - How to properly include HTML in android project? 如何在Android Studio中的库项目中包含库项目 - How to include library project in library project in Android Studio 如何在Android项目中包含Selenium库? - How to include selenium library in the android project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM