How to create a . jar file appropriately?

Asked

Viewed 6,165 times

1

I, who am totally new to Java, am trying to compile a "Hello, World!" project. I followed a few steps of this topic Stack Overflow in English. I followed all the steps, but when I open my jar, it’s wrong. I opened it, and I saw that it was the manifest’s fault. I searched, but so far I haven’t found any way to add the main class in the manifest. What I should do?

  • 2

    Hello, can you put in question the command you made to generate the jar? The contents of the manifest and the error message will also greatly help people trying to help you.

  • Hehehe, it was a Wiki question :P

  • Um, maybe there should be a tag to indicate these questions that the person themselves wants to answer.

  • Worse than only in the PT that has not yet '-'. Can be done as "community wiki" in Stack Overflow in English.

  • 1

    Essentially questions should not be wiki. Almost every situation where a question should be wiki, there is something wrong with it. I don’t understand what this '-' you say is missing. @C.E.Gesser should not have this kind of tag, this is called a metatag and adds nothing to the question.

  • @bigown All right, sorry, and '-' is the same thing as , is an "Emoticon" (e.g. - :D)

  • @Lucashenrique If you think you should, you can open a request or bug in the meta to have.

  • @bigown Hahahaha, I’m not asking for "'-' ", but community wiki

Show 3 more comments

1 answer

4


That’s a very common question. The compilation of a manifesto is external, using the -m. In this case, for example, the steps would be:

  1. javac HelloWorld.java - create the . class
  2. Create a.mf manifest with the following content: Main-Class: HelloWorld
  3. Simply compile with tags jar cvmf manifesto.mf arquivo_jar_desejado.jar HelloWorld.class

<Oracle & Sun>

<External>

Browser other questions tagged

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