[HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Moderator: admin
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
[HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Hi, hoping someone can provide some clarity, as I feel silly asking a basic question.
I'm getting an error "no main manifest attribute, in accounting.jar" when I'm trying out the command java -jar accounting.jar. Here were the steps I took, following the Study Guide:
create a mymanifest.txt file with the manifest information:
Manifest-Version: 1.0
Created-By: 1.7.0_09-b05 (Oracle Corporation)
Main-Class: accounting.Account
-cvfm accounting.jar mymanifest.txt accounting (no issues, it printed added manifest, adding:...etc.)
java -jar accounting.jar (this is where I get the error)
I'd really appreciate any help offered! Thanks in advance.
I'm getting an error "no main manifest attribute, in accounting.jar" when I'm trying out the command java -jar accounting.jar. Here were the steps I took, following the Study Guide:
create a mymanifest.txt file with the manifest information:
Manifest-Version: 1.0
Created-By: 1.7.0_09-b05 (Oracle Corporation)
Main-Class: accounting.Account
-cvfm accounting.jar mymanifest.txt accounting (no issues, it printed added manifest, adding:...etc.)
java -jar accounting.jar (this is where I get the error)
I'd really appreciate any help offered! Thanks in advance.
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
1. Check if you have only one jar and you are running that jar.
2. Extract the contents of that jar and very that it has apprpriate manifest.mf file and the required entry in that file.
3. If you still have the problem, I can try logging in remotely to your mc using teamviewer. let me know by sending an email to support@enthuware
Paul.
2. Extract the contents of that jar and very that it has apprpriate manifest.mf file and the required entry in that file.
3. If you still have the problem, I can try logging in remotely to your mc using teamviewer. let me know by sending an email to support@enthuware
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Thanks for this tip,
I was able to examine the jar, and in the manifest, no 'main-class:' is there, even though I have it defined in the text file mymanifest.txt. Could there be something wrong with the txt file?
MANIFEST.MF:
Manifest-Version: 1.0
Created-By: 1.7.0_09-b05 (Oracle Corporation)
mymanifest.txt:
Manifest-Version: 1.0
Created-By: 1.7.0_09-b05 (Oracle Corporation)
Main-Class: accounting.Account
-Wendell
I was able to examine the jar, and in the manifest, no 'main-class:' is there, even though I have it defined in the text file mymanifest.txt. Could there be something wrong with the txt file?
MANIFEST.MF:
Manifest-Version: 1.0
Created-By: 1.7.0_09-b05 (Oracle Corporation)
mymanifest.txt:
Manifest-Version: 1.0
Created-By: 1.7.0_09-b05 (Oracle Corporation)
Main-Class: accounting.Account
-Wendell
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Why does it say Created-By: 1.7.0_09-b05?
Are you using java 7!
Are you using java 7!
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Thanks for your help!
I had simply copied the text from the book, which may have been written during the time of Java 7 (?)
I have also figured out the solution.
I've just learned that with manifest files, a blank line is necessary at the end of the file. I did not have that before, but now it works. Thanks again! I'm sure I'll have more questions in the future, but I appreciate the time now as well.
I had simply copied the text from the book, which may have been written during the time of Java 7 (?)
I have also figured out the solution.
I've just learned that with manifest files, a blank line is necessary at the end of the file. I did not have that before, but now it works. Thanks again! I'm sure I'll have more questions in the future, but I appreciate the time now as well.
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Good point. Thanks for posting the resolution. It should be updated in the book also.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Hoping you can provide one more piece of guidance.
I'm now moving into creating jar files with a custom manifest, but am getting that pesky ClassNotFoundException that I've seen so much in Google searching. I can't seem to get past it.
When I compile and run the code outside of the jar, it works fine. But when I create the jar and then try to execute the jar file, it throws the exception. I'm suspecting it's something in my manifest Main-Class attribue. Here's my manifest:
Manifest-Version: 1.0
Created-By: wdphipps (Some Corperation)
Main-Class: com.enthuware.packTwo.ClassTwo
(blank line here)
Any idea what the issue is?
I'm now moving into creating jar files with a custom manifest, but am getting that pesky ClassNotFoundException that I've seen so much in Google searching. I can't seem to get past it.
When I compile and run the code outside of the jar, it works fine. But when I create the jar and then try to execute the jar file, it throws the exception. I'm suspecting it's something in my manifest Main-Class attribue. Here's my manifest:
Manifest-Version: 1.0
Created-By: wdphipps (Some Corperation)
Main-Class: com.enthuware.packTwo.ClassTwo
(blank line here)
Any idea what the issue is?
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Generally, the only issue that usually causes CNF is that your class file is not stored in the right path within the jar. Email me your jar and I can take a look.
If you are online right now, I can login to your m/c remotely using teamviewer and see what's going on.
Paul.
If you are online right now, I can login to your m/c remotely using teamviewer and see what's going on.
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Email is on the way!
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
I'm available right now if an admin currently is as well.admin wrote: ↑Thu Sep 26, 2019 11:20 pmGenerally, the only issue that usually causes CNF is that your class file is not stored in the right path within the jar. Email me your jar and I can take a look.
If you are online right now, I can login to your m/c remotely using teamviewer and see what's going on.
Paul.
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Looks like you shared it on google drive. requires permission to download.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Granted - gmail doesn't allow me to send jars as-is for some reason
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
You have a mistake in your main-class entry in manifest file. In the manifest, you have com.enthuware.packTwo.ClassTwo
but the package is com.enthuware.packtwo.ClassTwo (packtwo is in lower case).
but the package is com.enthuware.packtwo.ClassTwo (packtwo is in lower case).
If you like our products and services, please help us by posting your review here.
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Not related, but you shouldn't have the java files and mymanifest.txt in the jar file.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Mon Sep 23, 2019 4:55 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Thanks for that catch. The jar now works.
So it's better practice to only have the class files in the jar file?
In that case, i would only put the package and its contents in the jar file, correct?
So it's better practice to only have the class files in the jar file?
In that case, i would only put the package and its contents in the jar file, correct?
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 1.8.3 - packaging-classes-into-jar] - no main manifest attribute
Yes.
Yes.In that case, i would only put the package and its contents in the jar file, correct?
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 210 guests