Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-01-2008, 09:05 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
Creating jarfile containing external jarfiles
Hi there,
I am trying to create a jar file that containing external jarfiles.I copied that external files into my location and create the manifest file Manifest.mf as below:

Main-Class: MainClass
Class-Path: jar1.jar jar2.jar ...

and create the jar file using the command :

jar cfm MyJar.jar Manifest.mf *

I can execute this MyJar.jar at the location where I create that jar file..when am trying to execute it in another location its showing an exception regarding the external jar file such as java.lang.NoClassDefFoundError

can anybody please help me........
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-01-2008, 10:06 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Before go further, move your newly create jar file into a different location. Then try to execute it, ok you say that you can't.

Then extract the jar file on to the same location and try to execute the same jar file. What happened?

I hope you use Netbeans for developing your java applications.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-01-2008, 10:18 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
Thanks for your reply
Yes. I moved that jar file in to another location and extract its content there. its executing.But I have a doubt ,is it the real way to execute a jar file?

I create that jar file using the command jar cfm.......
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-01-2008, 10:40 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
No it's not the real way to execute a jar file. Seems that additional jar file make not refer the resources correctly.

Did you have any addition resources in you project. I mean did you use addition folder for images or any. Those make not linked correctly.

Quote:
Originally Posted by gowry
I create that jar file using the command jar cfm.......
Even that addition jar files?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-01-2008, 10:57 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
No.The only additional things are the external jar files that I copied to my location for creating my jar file.




Quote:
Originally Posted by Eranga View Post
Even that addition jar files?
That additional jar files are java3d libraries that are using in my project.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-01-2008, 12:58 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I never done this on notepad. Most of the IDEs gives the final jar files binding with all required libraries.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-01-2008, 01:37 PM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
I tried to create jar file in Eclipse.but it gives the same exception as in the situation when am trying to excecute the created jar file in another location.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 04-01-2008, 01:42 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I don't know to say about Eclipse. I used Netbeans. There is a folder named 'dist' is created and that is the distribution package. There is a single jar file is included if you don't have use any libraries. If you use, there is a folder created inside the dist folder named lib.

So all the time you have to use whole dist folder as your package. Rather using a single file. I've never try to make a single jar file, because in deploying I keep the same folder structure.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 04-01-2008, 03:30 PM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
Thank you for the time spent here..
But Still am in the middle of sea...
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 04-02-2008, 05:40 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by gowry View Post
Thank you for the time spent here..
Don't worry. It's pleasure to help to solve your question.

Quote:
Originally Posted by gowry View Post
But Still am in the middle of sea...

You mean that, try on Netbeans and the result is same?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 04-02-2008, 08:55 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
Yes.. I tried on NetBeans..As you wrote there is a dist folder and all the libraries are within that in the lib folder.. Jar file is executing in that location..
But if i move that jar file into another location still there the same Exception..
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 04-02-2008, 08:56 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
And as you said, if the jar file is extracted it works, right?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 04-02-2008, 09:03 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
No. Its not working even after extracting the jar file.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 04-02-2008, 09:16 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by gowry View Post
No. Its not working even after extracting the jar file.

So you said inside the dist folder it works, and out of it it's not? Try it clean and build, then move the dist folder somewhere and try.

Is that you application(code) is too large. If you are ok to send it here or PM to me, I can try. If you don't like to do it, I don't I always
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 04-02-2008, 09:42 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
Yes .Inside the dist folder its working.
executing the moved jar file after clean and build reporting an exception :

Failed to load Main-Class manifest attribute from
JarFile.jar
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 04-02-2008, 09:45 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, after extracting the jar file you should have a folder name, META-INF, is that right. Check the file there, what is the content of it. Check there Main-class attribute, is that main class of your application?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 04-02-2008, 10:00 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
There is no Main-Class attribute in the manifest file under the META-INF folder. that containing only the version and other such informations.
Bookmark Post in Technorati
Reply With Quote
  #18 (permalink)  
Old 04-02-2008, 10:05 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
That should be the error in this case. Because Main-class define the main class, or the starting point of the jar file.

Here is an example of one of my project.

Quote:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 10.0-b19 (Sun Microsystems Inc.)
Main-Class: testproject.StartingPoint
Class-Path: lib/beansbinding-1.2.1.jar lib/AbsoluteLayout.jar
X-COMMENT: Main-Class will be added automatically by build
See the last line, X-COMMENT, says that Main-class should be added automatically in the build.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #19 (permalink)  
Old 04-02-2008, 10:11 AM
gowry's Avatar
Member
 
Join Date: Apr 2008
Location: India
Posts: 27
gowry is on a distinguished road
Yes.In that case the abscense of main class in the manifest is the error.ok.. but with the previous manifest file before the clean and build and the manifest file I created myself ,having those attributes Class-Path and M