Problem running manually compressed jar

Asked

Viewed 57 times

0

I was studying how to compile java straight through javac and everything else. Then I joined all the files into a zip and renamed it . jar . It didn’t work at first due to lack of Manifest - didn’t find the main class'

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

When I added the manifest I appeared to Mensagen : Invalid or corrupted jarfile

I had a hypothesis that a jar would not be exactly a zip, but even if I extracted a jar(functional) and compacted again, nothing wrong happens. What mistake I made then?

  • What is the doubt? Apparently you yourself clarified in the text.

  • I edited, I think I’m really bad at making things clear

  • Vc compact the files that belong to the jar to zip, and changed the extension to jar? If that’s what it was, I don’t think it’s gonna run at all, I’m not sure if it runs normal.

  • There is a tool that is part of the SDK that serves for this. Have a look at https://docs.oracle.com/javase/tutorial/deployment/jar/build.html . If you don’t succeed because of English, please let me know that I will give you a full reply in Portuguese as soon as I can test.

1 answer

0

To generate a . jar you cannot just compress it. You must compile your source code (.java) to generate a bytecode (.class). JVM interprets only this type of file.

Follow the link of material on this subject => http://www.devmedia.com.br/etapas-do-desenvolvimento-e-execucao-de-uma-aplicacao-java/25099

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.