Problem when running manually compressed jar

0

I was studying how to compile java directly from javac and everything. Then I put all the files in a zip file and renamed it to .jar. It did not work first because of the lack of Manifest - it did not 'find the main class'

But even if I entered directly using -cp the error persists.

When I added the manifest the message appeared: Invalid or corrupted jarfile

I had a chance that a jar would not exactly be a zip, but even though I'm extracting a jar (functional) and compressing again, nothing wrong happens. What error did I make then?

    
asked by anonymous 12.01.2016 / 02:25

1 answer

0

To generate a .jar you can not just compress it. You must compile your source code (.java) so that a bytecode (.class) is generated. The JVM interprets only this type of file.

Follow the link for a material on this subject = > link

What you could do is use javac to generate the .class files (bytecodes) and then compress them using Winrar. Along with the compressed files, you must include the manifest with the path of the main class (the class that has the public static void mamin (String args) method)

    
12.01.2016 / 21:22