Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

jar files in eclipse build path library

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a pretty big project that has bunch of jar files in its build path libraries. Some of the jar files may not really used. If I remove a particular jar and the project still builds well (compile), can I say the project doesn't need it ?  By the way, the project is j2ee web application running on tomcat 8.x.  I am afraid if I delete the jar file, it may impact the application when it runs, although it builds fine.  Is my concern valid ? thanks
 
Ranch Hand
Posts: 104
2
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There could be a case that
your project depends on -> jar1

jar1 depends on jar2.

If you remove jar2 from build path (since your project directly doesn't use it) it will build successfully since jars are not compiled during build. But it may fail in run-time with NoClassDefFoundError.

 
Saloon Keeper
Posts: 24595
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jack Mutansan wrote:I have a pretty big project that has bunch of jar files in its build path libraries. Some of the jar files may not really used. If I remove a particular jar and the project still builds well (compile), can I say the project doesn't need it ?



No, because Java allows dynamic class loading and introspection. That means that you can require a class even though you don't code its name explicitly in compiled code.

The opposite is also true, and JEE is a good example of that. You need a servlet API jar to compile webapps containing servlet code, but you don't include the jar in the webapp, because it's defined as part of the server and is part of the inherited classpath of the webapp. And the API jar itself is backed by implementation classes within the server itself.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic