Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
jar file created by Eclipse doesn't run

I recently installed the last version of Eclipse on my pc running on Windows 10. Every time I try to export the simplest Java project in a runnable jar file, the jar file doesn't work.

Example:

import javax.swing.JOptionPane;
public class Try {
    public static void main(String[] args) {
        JOptionPane.showMessageDialog(null, "Some message", "title!!", JOptionPane.INFORMATION_MESSAGE);
    }
}

File> Export> Java > Runnable Jar File All names/ Folders been set OK Package required libraries into generated JAR (but I tried every other switch )> Finish The jar file is created but doesn't make anything at all. Any suggestions?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Not sure if this is your issue, but your jar needs to contain a manifest file to indicate which class within the jar is the application's entry point. So it may be worth checking whether Eclipse is adding that correctly. Looks like some manual steps may be involved. The file (META-INF/MANIFEST.MF) should contain contents such as:

Manifest-Version: 1.0
Created-By: 1.8.0_112 (Oracle Corporation)
Main-Class: MyClass

For reference, some guidance on adding the manifest (outside of Eclipse) can be found here.

FYI, if you do end up adding a manifest manually, be sure to follow this advice from that page to add a new line at the end of the file. Missing it, as I have, can lead to much frustration:

Warning: The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

You would create a file, say Manifest.txt, containing this (plus a "new line"):

Main-Class: Try

Then create the jar:

jar cfm anyname.jar Manifest.txt Try.class

And then run the jar by double clicking it or by running this:

java -jar anyname.jar
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda