Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » common jar in more projects
common jar in more projects [message #721671] Fri, 02 September 2011 13:53 Go to next message
chiara  is currently offline chiara Friend
Messages: 2
Registered: September 2011
Junior Member
Hi,

I've 3 projects in Eclipse:

1- "UtilityProject" and into the classpath I have added "log4j.jar"

2- "ProjectB" that uses "utilityProject.jar" and "log4.jar". I have added into the classpath "utilityProject.jar" and "log4j.jar"

3- "ProjectC" that uses "utilityProject.jar" and "log4.jar" and "projectB.jar". I have added into the classpath "utilityProject.jar" and "log4j.jar" and "projectB.jar"

It works but..

Is there a way to use "log4j.jar" in others projects without add directly "log4j.jar" into their classpath?


My situation:

UtilityProject
        LIB -> Log4j.jar 

ProjectB
        LIB -> Log4j.jar
               UtilityProject.jar

ProjectC
        LIB -> log4j.jar
               UtilityProject.jar
               projectB.jar



What I want:
UtilityProject
	LIB -> Log4j.jar

ProjectB
	LIB -> UtilityProject.jar

ProjectC:
	LIB -> projectB.jar

Re: common jar in more projects [message #721686 is a reply to message #721671] Fri, 02 September 2011 14:46 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 02-Sep-11 07:53, chiara wrote:
> Hi,
>
> I've 3 projects in Eclipse:
>
> 1- "UtilityProject" and into the classpath I have added "log4j.jar"
>
> 2- "ProjectB" that uses "utilityProject.jar" and "log4.jar". I have
> added into the classpath "utilityProject.jar" and "log4j.jar"
>
> 3- "ProjectC" that uses "utilityProject.jar" and "log4.jar" and
> "projectB.jar". I have added into the classpath "utilityProject.jar" and
> "log4j.jar" and "projectB.jar"
>
> It works but..
> Is there a way to use "log4j.jar" in others projects without add
> directly "log4j.jar" into their classpath?
>
> [snip]


The short answer is no (I'm pretty sure), but there is a way, at least
for Dynamic Web Projects, to share their classpath entries with other
projects "automatically" by using Build Path -> Configure Build Path ->
Libraries tab -> Add Library... -> Web App Libraries.

There is also a way, though it's not very portable because it involves
full paths in your host's filesystem, of creating one or more User
Libraries that you can more easily add to new projects inside your
workspace. A User Library can be composed of any JARs you like including
source code and Javadoc wiring, then added (via Build Path) to the new
project.

If you like, see
http://www.javahotchocolate.com/tutorials/jar-libraries.html

Hope this helps.
Re: common jar in more projects [message #721705 is a reply to message #721686] Fri, 02 September 2011 15:06 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 09/02/2011 09:46 AM, Russell Bateman wrote:
> On 02-Sep-11 07:53, chiara wrote:
>> Hi,
>>
>> I've 3 projects in Eclipse:
>>
>> 1- "UtilityProject" and into the classpath I have added "log4j.jar"
>>
>> 2- "ProjectB" that uses "utilityProject.jar" and "log4.jar". I have
>> added into the classpath "utilityProject.jar" and "log4j.jar"
>>
>> 3- "ProjectC" that uses "utilityProject.jar" and "log4.jar" and
>> "projectB.jar". I have added into the classpath "utilityProject.jar" and
>> "log4j.jar" and "projectB.jar"
>>
>> It works but..
>> Is there a way to use "log4j.jar" in others projects without add
>> directly "log4j.jar" into their classpath?
>>
>> [snip]
>
>
> The short answer is no (I'm pretty sure), but there is a way, at least
> for Dynamic Web Projects, to share their classpath entries with other
> projects "automatically" by using Build Path -> Configure Build Path ->
> Libraries tab -> Add Library... -> Web App Libraries.
>
> There is also a way, though it's not very portable because it involves
> full paths in your host's filesystem, of creating one or more User
> Libraries that you can more easily add to new projects inside your
> workspace. A User Library can be composed of any JARs you like including
> source code and Javadoc wiring, then added (via Build Path) to the new
> project.
>
> If you like, see
> http://www.javahotchocolate.com/tutorials/jar-libraries.html
>
> Hope this helps.
Yes, you can do this. In the Utility project go to the Build Path
dialog and select the Order and Export tab. Click on the log4j.jar.

In the ProjectB Build Path dialog go to the Project References page and
add Utility project. Export Utility project from ProjectB

Do similar for ProjectC.
Re: common jar in more projects [message #722084 is a reply to message #721705] Sun, 04 September 2011 10:58 Go to previous message
chiara  is currently offline chiara Friend
Messages: 2
Registered: September 2011
Junior Member
dpwegener wrote on Fri, 02 September 2011 11:06
On 09/02/2011 09:46 AM, Russell Bateman wrote:
> On 02-Sep-11 07:53, chiara wrote:
>> Hi,
>>
>> I've 3 projects in Eclipse:
>>
>> 1- "UtilityProject" and into the classpath I have added "log4j.jar"
>>
>> 2- "ProjectB" that uses "utilityProject.jar" and "log4.jar". I have
>> added into the classpath "utilityProject.jar" and "log4j.jar"
>>
>> 3- "ProjectC" that uses "utilityProject.jar" and "log4.jar" and
>> "projectB.jar". I have added into the classpath "utilityProject.jar" and
>> "log4j.jar" and "projectB.jar"
>>
>> It works but..
>> Is there a way to use "log4j.jar" in others projects without add
>> directly "log4j.jar" into their classpath?
>>
>> [snip]
>
>
> The short answer is no (I'm pretty sure), but there is a way, at least
> for Dynamic Web Projects, to share their classpath entries with other
> projects "automatically" by using Build Path -> Configure Build Path ->
> Libraries tab -> Add Library... -> Web App Libraries.
>
> There is also a way, though it's not very portable because it involves
> full paths in your host's filesystem, of creating one or more User
> Libraries that you can more easily add to new projects inside your
> workspace. A User Library can be composed of any JARs you like including
> source code and Javadoc wiring, then added (via Build Path) to the new
> project.
>
> Hope this helps.
Yes, you can do this. In the Utility project go to the Build Path
dialog and select the Order and Export tab. Click on the log4j.jar.

In the ProjectB Build Path dialog go to the Project References page and
add Utility project. Export Utility project from ProjectB

Do similar for ProjectC.




I created "utilityProject"
I added log4j in buildPath
BuildPath -> Configure Build Path -> Order And Export -> checked log4j.jar

I created "ProjectB"
BuildPath -> Configure Build Path -> Project References -> checked UtilityProject
BuildPath -> Configure Build Path -> Projects -> Add -> checked UtilityProject
BuildPath -> Configure Build Path -> Order And Export -> checked Utilityproject

I created "ProjectC"
BuildPath -> Configure Build Path -> Project References -> checked ProjectB
BuildPath -> Configure Build Path -> Projects -> Add -> checked ProjectB

I export ProjectC as Java Runnable JAR
It works.
Thank you very much.
Regards Smile

[Updated on: Sun, 04 September 2011 10:58]

Report message to a moderator

Previous Topic:Why can't I reply to posts?
Next Topic:Reasons for backtracking while coding
Goto Forum:
  


Current Time: Thu Apr 25 21:04:28 GMT 2024

Powered by FUDForum. Page generated in 0.08683 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top