Adding Libraries to a Dynamic Web Application in Eclipse

Posted: November 6, 2007 in Eclipse, Java, Programming Languages

I am currently developing a simple web application that would apply the MVC architecture. To those new to the MVC term, it stands for Model-View-Controller. An architecture used for simple applications that separates the GUI pages (for end client), the business logic (reusable classes), and the controller (that controls the event or method call). You can easily implement this in Eclipse by creating a new Dynamic Web Application project.

Apparently, during the development process, I’ve encountered a simple yet very important problem. My Database related classes can’t locate the classes from Postgre (which is my database system). This is due to the Library from Postgre that my code is looking.

The big question now – “How will I add a library in my Dynamic Web Project?”

Well, in a simple Java Project, this is easy but for a project of this kind where your sources are placed in a separate directory scheme it is the other way around.

I found this thread and it worked:

http://dev.eclipse.org/newslists/news.eclipse.webtools/msg11326.html

The solution is quite straightforward:
– Right click on the your web project and choose PROPERTIES
– Choose the J2EE Module Dependencies
– Click on the Add External JARs… and then point on your library file (ZIP or JAR)
– Click on Apply then OK.
– Restart your Apache Tomcat

The added library should be seen under: ProjectName > Java Resources: src > Libraries > WebApp Libraries.

ARMAN

About these ads
Comments
  1. balder says:

    Hmm, you can just place the needed jars into /WEB-INF/libs and they will be added to the classpath too ?

  2. fionixe says:

    eherm eherm… ^_^ sori i can’t see anything where i could just leave a message ^_^ eniway~ musta na po ? ^____^

  3. ajison says:

    Hello Balder,

    Thanks for the info. I tried your suggestion and it worked! :D

    — arman

  4. ajison says:

    Thanks Fiona for visiting. It’s been a while since I heard from you. Hope everything is fine with your work now. Please extend my regards to our JPCS and Baste friends.

    — arman :D

  5. balder says:

    @ajison
    glad I could be of help

  6. marco says:

    Exactly what I am searching for. What an incredible resource the web ! Thankyou !

  7. tosvneson says:

    You are a live saver

    cheers

  8. Jess says:

    oh man, i love simple guides for the uber noobs in Eclipse. <3

  9. su says:

    Thank u so much. i faced this problem for a long time. Now ok la.. thanks a lot

  10. reki says:

    Hi,

    It worked (at least for me). Nice post.

    Iker.

  11. xylevi says:

    Hi

    I had this problem, I found this post and IT WORKED.

    thx

  12. jalone says:

    grazie mille!!!

  13. wmi says:

    Thanks a lot for sharing …

  14. jmendes says:

    Excelent! Saved me from pulling my hair out! Thank you!!!

  15. BethB says:

    Thank you! This is just what I couldn’t figure out! You rock.

  16. Bob Fletcher says:

    Thank you! You have saved me a lot of time…

  17. downeyt says:

    I do not have the J2EE Module Dependencies in my Properties.

    It seems odd that libraries cannot be added to a project from within the IDE.

  18. uriel says:

    I haven’t “J2EE Module Dependencies” where can I find him ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s