• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Importing vs Java Build Path

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm wondering what is the difference between Importing a JAR file using File -> Import and adding JAR file into "Libraries" tab in Java Build Path ?

Thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Viji,
Welcome to JavaRanch!

If the source code is available, using file --> import will allow you to modify it. If the source is not available or you don't want to modify it, you should leave it as a jar. For example log4j.jar should be left as a jar to signify that it is untouched. This also allows things in your workspace to compile faster.
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, it may be of interest to know that putting a jar file into your build path in a Web Application (I am assuming you are using WSAD since this is the WebSphere forum) will only help at compile time. Not runtime in the Test Environment.

Putting the jar file in the build path of a Java Project will be effective at both compile time and run time.

It's like Jeanne stated, if you have a need to modify the code, importing the jar should break it out for you so that you can modify it. In which case you may want to keep it in a separate Java Project. If you plan on using this Java Project in a Web Application, you should put the project in the Web Application's list of web Library projects (right click->properties->web library project). Otherwise, if you plan on using this code in another Java Project just put the newly created Java Project in the build path....
 
Viji Laxmi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reponse.

In WSAD 5.0 when I go to project properties there are 2 options

- Java JAR Dependencies
- Java Build Path

In Java Build Path I could see several JARs including classes12.jar, jazp.jar etc. under Libraries.

But I don't see anything under Java JAR Dependencies. Is this option needed if current project is dependent on another project ?
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Viji Laxmi:
But I don't see anything under Java JAR Dependencies. Is this option needed if current project is dependent on another project ?


If the current project is a Web or EJB project, this option is needed. Java JAR dependencies need to be set regardless of whether the other code is a jar or other project. The only exception are those libraries you mentioned (because those are already on the server classpath.)
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic