GeeCON Prague 2014*
The moose likes IDEs, Version Control and other tools and the fly likes Question about creating a jar file with eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Question about creating a jar file with eclipse" Watch "Question about creating a jar file with eclipse" New topic
Author

Question about creating a jar file with eclipse

joe black
Ranch Hand

Joined: Dec 03, 2003
Posts: 103
I am trying to design a layered application, and I am creating a workspace for each layer.

I first started with the persistence layer. It uses hibernate, and now I want to create a jar file so that the other layers can use it as a dependency.

I placed all the hibernate jars in src/lib, and all source files are under src/java. However, after creating a jar using export->jar file, and adding it to the other project's build path, it cannot find any of the hibernate stuff.

I assume I am not understanding how to use the java build path correctly.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Did you add the JARs into your project properties ?
RightClick your project -> Properties -> Java Build Path -> Libraries


[My Blog]
All roads lead to JavaRanch
joe black
Ranch Hand

Joined: Dec 03, 2003
Posts: 103
I added the hibernate jars to the project properties of the persistence layer. Do I need to add the hibernate jars to the other projects as well?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Of course. How should Eclipse know that you intended for there to be a relationship between the two projects?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Yes, you need to add the reference to external jars wherever you use them.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I wouldn't use the jar for the other projects, but let them depend directly on the persistence project. The persistence project can then export the dependencies on hibernate et al.

This way it's easier to test how the projects work together and it enables easy cross-project refactorings, while still making sure that you don't get any undesired code dependencies.

You can still use the different jar files for distribution.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
GeeCON Prague 2014
 
subject: Question about creating a jar file with eclipse