Computernerd
Computernerd

Reputation: 7772

How to include an external library into your project properly

I am using the Keyczar Java library to encrpyt and decrpyt information.

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

enter image description here

What am i doing wrong ???

Download Keyczar from here

Upvotes: 0

Views: 1041

Answers (3)

Vishrant
Vishrant

Reputation: 16678

To include external library/ JARs into your project follow following steps:

  • 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. As shown in below image:

enter image description here

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.

enter image description here

Also in your above code I can see that there is no import statement for Crypter class. If you have added external JARs by following above procedure, then you can press Ctrl + Shift + O to solve import problems in Eclipse.

Upvotes: 2

Switch
Switch

Reputation: 15463

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.

As per long term project maintainability and sustainability it's good if you use a project management tool like Maven or Ant

Upvotes: 1

Sambhav Sharma
Sambhav Sharma

Reputation: 5860

I would suggest you to use 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.

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.

Upvotes: 1

Related Questions