Dosent work with creating jar file?
Hi i input this in ms-dos:
jar cf Pass2.jar Pass2.class manifest.mf
and it dosen't give a message in return, wich is good i think
but the when i run Pass2.jar, it says:
"Failed to load Main-Class manifest attribute from H:\program\...\Pass2.jar"
in the manifest.mf i have:
Main-Class: Pass2
plz help!
[350 byte] By [
Ogara] at [2007-11-27 9:47:25]

# 1
try this:jar cvfm Pass2.jar Pass2.class META-INF/manifest.mfappend two empty lines to the end of your manifest.mf fileLet us know what happens
# 2
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:389)
at java.util.jar.Manifest.read(Manifest.java:182)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:132)
at sun.tools.jar.Main.main(Main.java:1022)
that is the reply...:/
Ogara at 2007-7-12 23:59:50 >

# 3
> java.io.IOException: invalid header field
> at
> java.util.jar.Attributes.read(Attributes.java:389)
> at
> java.util.jar.Manifest.read(Manifest.java:182)
> at
> java.util.jar.Manifest.<init>(Manifest.java:52)
> at sun.tools.jar.Main.run(Main.java:132)
> at sun.tools.jar.Main.main(Main.java:1022)
>
> that is the reply...:/
I think what was meant is:jar cvfm Pass2.jar manifest.mf Pass2.class
# 4
If i input that it works, but when i run the .jar file, it comes upp an error message:"Could not find main class. Program will now exit"plz anyone help? :)
Ogara at 2007-7-12 23:59:50 >

# 5
How are you running the jar file? Does your application work when it is not jar'ed?Is Pass2 class in a named package? If it is, then Main-Class needs to khave the fully qualified class name.
# 6
And did you put at least one blank line at the end of the manifest.mf file?
# 7
i running the Jar file from ms-dos with the command "Pass2.jar".My app work when not jar'ed, yes. No, its not in a package. And i have 2 empty lines in the manifest.mf.
Ogara at 2007-7-12 23:59:50 >

# 8
> i running the Jar file from ms-dos with the command> "Pass2.jar".Do you meanjava -jar Pass2.jar
# 9
No. just "Pass2.jar"I tried that u just said, and the reply is:Exception in thread "main" java.lang.NoClassDefFoundError: Pass2/class
Ogara at 2007-7-12 23:59:50 >

# 10
> No. just "Pass2.jar"
>
> I tried that u just said, and the reply is:
>
> Exception in thread "main"
> java.lang.NoClassDefFoundError: Pass2/class
That sounds like your mainifest has "Pass2.class" instead of just "Pass2"
Also, you can try java -classpath Pass2.jar Pass2
# 11
Weey it works with your classpath thing!:)So is the .jar file done now?
Ogara at 2007-7-12 23:59:50 >

# 12
> Weey it works with your classpath thing!:)> That proves that your manifest is wrong in some way.> So is the .jar file done now?I'm not sure what you mean.
# 13
Well if i send the jar file to someone else, they can execute it?:p
Ogara at 2007-7-12 23:59:50 >

# 14
Follow these steps plz:
1 - create a META-INF directory
2 - under the directory META-INF just created, create a manifest file manifest.mf:
Main-Class: Pass2
<empty line>
<empty line>
3 - put Pass2.class in the same directory as META-INF. Suppose this directory is called Pass2Project:
-Pass2Project :
++ META-INF/
++ Pass2.class
4 - Open MS-DOS and go to Pass2Project directory and type:
jar cvfm Pass2.jar META-INF/manifest.mf *.class
5 - Execute your jar like the following: java -jar Pass2.jar
NB: if your Pass2 java class is included in a package (suppose com.company.project), you should have this:
-Pass2Project :
++ META-INF/
++ com/company/project/Pass2.class
In this case, create your jar like as follows: jar cvfm Pass2.jar META-INF/manifest.mf *
Hope That Helps
# 15
> Well if i send the jar file to someone else, they can> execute it?:pThey can execute it if they have a jvm and they use the same command line you used to execute it. If you want them to be able to double click to run it, then you need to fix the manifest.