• Post Reply Bookmark Topic Watch Topic
  • New Topic

jar doesn't recognize another jar  RSS feed

 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I packed my java class and additional files into a jar file, using the eclipse.
The class I packed uses another jar file. it works fine.
the problem is with my new jar that I created, since it doesn't recognize the other jar that the class uses and can't use it,
Although I included the other jar in my class path in the eclipse.
i don't know how to make that the new jar will know the other jar.
thanks.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it some jar which you have created or some jar which is very common like j2ee.jar or ant-1.6.5.jar or ejb-3_0-api.jar? If the jar isn't recognized the class will not be able to use it in the first place. Could you please elaborate a little.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you added the Classpath entry to the jar's manifest file?
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If somebody knows how to add files into the manifest while generating a new jar (using eclipse),
i will be very glad to here !
thanks in advance !
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well in eclipse all you have to do is add the jar file in your build path. That can be done by going to Properties of the project and then selecting the Java Build Path-->Libraries. But i think you know that!

If its not working, download the plug-in called Fat-Jar for eclipse. Eclipse does have some problems in creating jar files.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
moshi cohen wrote:If somebody knows how to add files into the manifest while generating a new jar (using eclipse),

Did you even look at the link I had provided? Does it talk about adding files to the manifest?

moshi cohen wrote:i will be very glad to here !

I am sure you would.




 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh, thanks a lot for your help !
I wondered if there is a way to deal with it using eclipse.
The link you provided doesn't deal with eclipse, although it is very helpful !
Thanks again.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you try creating a jar in Eclipse, it asks you if you want to reuse an existing manifest file. Have you got to this step?
A simple google gave me http://www.fsl.cs.sunysb.edu/~dquigley/cse219/index.php?it=eclipse&tt=jar&pf=y

 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I saw now that it is really what I need.
Well, I tried it, and edited my manifest as:

Manifest-Version: 1.0
Main-Class: hasp_demo
Class-Path: h2-1.2.122.jar

Actually I added the last row.
I still get an exception telling me that my jar doesn't recognize the other jar !
What have I done wrong ???

Thanks for any help.
 
Arjun Abhishek
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can you change the order and export of the jar and dependencies in the eclipse.
Go to the properties of the project, in the java build path, the last tab you will find order and export. Make sure all the jar that are dependent to your jar are loaded before your jar.

PS: Though manifest in the jar is the right approach, this might help too.

cheers
K
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
moshi cohen wrote:
Actually I added the last row.

Did you rebuild your jar after editing the manifest? Did you tell eclipse to use this manifest file while building the jar?
 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh, you solve my problem ! I generated again the jar letting it the edited manifest I prepared, and it worked.
I only had to create the jar again.
Thanks a lot !
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done!
I have provided a link in my previous post. You might want to go through all the articles (displayed as hyperlinks on the left hand side of that page) listed there.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!