|
|
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.
|
|

04-01-2008, 09:05 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
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........ 
|
|

04-01-2008, 10:06 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

04-01-2008, 10:18 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
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.......
|
|

04-01-2008, 10:40 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
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.
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.
|
|

04-01-2008, 10:57 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
No.The only additional things are the external jar files that I copied to my location for creating my jar file.
Originally Posted by Eranga
Even that addition jar files?
That additional jar files are java3d libraries that are using in my project.
|
|

04-01-2008, 12:58 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

04-01-2008, 01:37 PM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
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.
|
|

04-01-2008, 01:42 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
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.
|
|

04-01-2008, 03:30 PM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
Thank you for the time spent here..
But Still am in the middle of sea...
|
|

04-02-2008, 05:40 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
Originally Posted by gowry
Thank you for the time spent here..
Don't worry. It's pleasure to help to solve your question.
Originally Posted by gowry
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.
|
|

04-02-2008, 08:55 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
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..
|
|

04-02-2008, 08:56 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

04-02-2008, 09:03 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
No. Its not working even after extracting the jar file.
|
|

04-02-2008, 09:16 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
__________________
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.
|
|

04-02-2008, 09:42 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
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
|
|

04-02-2008, 09:45 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

04-02-2008, 10:00 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
There is no Main-Class attribute in the manifest file under the META-INF folder. that containing only the version and other such informations.
|
|

04-02-2008, 10:05 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
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.
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.
|
|

04-02-2008, 10:11 AM
|
 |
Member
|
|
Join Date: Apr 2008
Location: India
Posts: 27
|
|
|
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 | | |