.Jar nao abre!

9 respostas
A

Ola , Fiz um projrto no NetBeans. Nele roda de boa, nais quando salvao, nao entra nao abre, nao da mensagen de erro, simplismente nada acontece ! (???)

No projeto nao criei UM MAIN PROJECT (projeto principal) mais criei uma classe main.

v/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package conversor;

/**
 *
 * @author User
 */
public class Conversor {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    }
}

E o outro :

package conversor;

/**
 *
 * @author User
 */
public class NewJFrame extends javax.swing.JFrame {
float real,dolar,conversao,conversao1;
    /**
     * Creates new form NewJFrame
     */
    public NewJFrame() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        PanelPrincipal = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        qtdDolar = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        RConversao = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        valorReal = new javax.swing.JTextField();
        jBcalcular = new javax.swing.JToggleButton();
        jBLimpar = new javax.swing.JToggleButton();
        RConversao1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        PanelPrincipal.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jLabel1.setText("Quantidade em Dolar $U");

        jLabel2.setText("Dolar para Real");

        RConversao.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        RConversao.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        RConversao.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        jLabel4.setText("Valor do Dolar em Real (R$)");

        jBcalcular.setText("Calcule");
        jBcalcular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBcalcularActionPerformed(evt);
            }
        });

        jBLimpar.setText("Limpar");
        jBLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLimparActionPerformed(evt);
            }
        });

        RConversao1.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        RConversao1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        RConversao1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        jLabel3.setText("Real para Dolar");

        javax.swing.GroupLayout PanelPrincipalLayout = new javax.swing.GroupLayout(PanelPrincipal);
        PanelPrincipal.setLayout(PanelPrincipalLayout);
        PanelPrincipalLayout.setHorizontalGroup(
            PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelPrincipalLayout.createSequentialGroup()
                .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelPrincipalLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel1)))
                    .addGroup(PanelPrincipalLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(RConversao, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelPrincipalLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(valorReal, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(qtdDolar, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(PanelPrincipalLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(RConversao1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())))
            .addGroup(PanelPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBcalcular)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBLimpar)
                .addContainerGap())
        );
        PanelPrincipalLayout.setVerticalGroup(
            PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelPrincipalLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(qtdDolar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(valorReal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(33, 33, 33)
                .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(RConversao, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(RConversao1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBcalcular)
                    .addComponent(jBLimpar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jMenu1.setText("Principal");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/conversor/images/exit-20120426-favicon.ico.png"))); // NOI18N
        jMenuItem1.setText("Sair");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Sobre");
        jMenu2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu2MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(PanelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PanelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void jBcalcularActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        dolar = Float.valueOf(qtdDolar.getText());
        real = Float.valueOf(valorReal.getText());
        conversao = (dolar / real);
        conversao1 = (dolar * real);
        RConversao.setText(String.valueOf(conversao));
        RConversao1.setText(String.valueOf(conversao1));
    }                                          

    private void jBLimparActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        qtdDolar.setText("");
        valorReal.setText("");
        RConversao.setText(null);
        RConversao1.setText(null);
    }                                        

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        System.exit(0);
    }                                          

    private void jMenu2MouseClicked(java.awt.event.MouseEvent evt) {                                    
        new JFrameSobre().show();
    }                                   

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JPanel PanelPrincipal;
    private javax.swing.JLabel RConversao;
    private javax.swing.JLabel RConversao1;
    private javax.swing.JToggleButton jBLimpar;
    private javax.swing.JToggleButton jBcalcular;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JTextField qtdDolar;
    private javax.swing.JTextField valorReal;
    // End of variables declaration                   
}

PoRque nao executa ??? (Obs: aNtes de fazer esse projeto eu fiz uma calculadora e abriu sem problema)

9 Respostas

InicianteJavaHenriqu

A pasta lib está junto com o .jar? Talvez esteja faltando alguma biblioteca.

:thumbup:

A

InicianteJavaHenrique:
A pasta lib está junto com o .jar? Talvez esteja faltando alguma biblioteca.

:thumbup:

Ola, bem desculpe-me mas o que e pasta lib ? Como saberei se esta jnto ao .jar e se nao tiver como colocar ?

Flws

InicianteJavaHenriqu

É a pasta de bibliotecas do seu projeto.

Você arrastou os componentes (botões, rótulos, caixas de texto…) e inseriu em seu JFrame no NetBeans, não é :?: O NetBeans usa uma biblioteca chamada layout absoluto (nas condições citadas anteriormente) que fica dentro da pasta lib.

Após você usar a opção limpar e construir do NetBeans ele criar a pasta do seu projeto e lá dentro fica a pasta lib exatamente em: pastaDoSeuProjeto/dist/lib. Você precisa executar o .jar (localizado na pasta dist) e deixar a pasta lib intacta.

Você também pode copiar o .jar e a pasta lib para qualquer outro lugar, mas ambos devem permanecerem juntos.

Se não der certo use a opção limpar e construir do NetBeans de novo.

:thumbup:

A

É a pasta de bibliotecas do seu projeto.

Após você usar a opção limpar e construir do NetBeans ele criar a pasta do seu projeto e lá dentro fica a pasta lib exatamente em: pastaDoSeuProjeto/dist/lib. Você precisa executar o .jar (localizado na pasta dist) e deixar a pasta lib intacta.

Você também pode copiar o .jar e a pasta lib para qualquer outro lugar, mas ambos devem permanecerem juntos.

Se não der certo use a opção limpar e construir do NetBeans de novo.

:thumbup:

Wlw pela informaçao :slight_smile:

É o seguinte, fiz o ‘clean and build’ fui na psta ‘dist’ porem so tem 2 arquivos, o programa (que nao abre) e um ‘READ-ME’ q Esta escrito isso :

========================
BUILD OUTPUT DESCRIPTION

When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).

To run the project from the command line, go to the dist folder and
type the following:

java -jar “JavaApplication26.jar”

To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.

Notes:

  • If two JAR files on the project classpath have the same name, only the first
    JAR file is copied to the lib folder.
  • Only JAR files are copied to the lib folder.
    If the classpath contains other types of files or folders, these files (folders)
    are not copied.
  • If a library on the projects classpath also has a Class-Path element
    specified in the manifest,the content of the Class-Path element has to be on
    the projects runtime path.
  • To set a main class in a standard Java project, right-click the project node
    in the Projects window and choose Properties. Then click Run and enter the
    class name in the Main Class field. Alternatively, you can manually type the
    class name in the manifest Main-Class element.
InicianteJavaHenriqu

Anexe o programa aqui na mensagem para ver se funciona. Tô achando que sua VM está corropida.

:thumbup:

A

InicianteJavaHenrique:
Anexe o programa aqui na mensagem para ver se funciona. Tô achando que sua VM está corropida.

:thumbup:

Cara ta aew

InicianteJavaHenriqu

Quando você abrir o projeto no NetBeans exclui o arquivo Thumbs.db que está no pacote conversor.images

E não instancie o JFrame new NewJFrame().setVisible(true); dentro da classe NewJFrame(); instancie dentro do método main da classe Conversor.

:thumbup:

A

InicianteJavaHenrique:
Quando você abrir o projeto no NetBeans exclui o arquivo Thumbs.db que está no pacote conversor.images

E não instancie o JFrame new NewJFrame().setVisible(true); dentro da classe NewJFrame(); instancie dentro do método main da classe Conversor.

:thumbup:

OHo Valeu agora esta abrindo d boua. So mais uma coisa, para eu nao prescisar criar~outro topico :arrow:

qUero fazer um outro projeto no Netbeans, qual vc me indica ja que eu sou iniciante ??? Queria fazer um jogo, de imediato simples como um jogo-da-velha, é facil criar ele ? ‘Obrigado’

InicianteJavaHenriqu

Tem bastante ideias aqui neste site :arrow: http://www.ebah.com.br/content/ABAAAAUGoAE/300-ideias-programar-computadores podendo ser implementados via console e/ou GUI.

A ideia do jogo da velha também é muito legal, fiz um há algum tempo, como sugestão você pode fazer com botões (3x3) e futuramente reescrevo-lo utilizando Java 2D.

:thumbup:

Criado 5 de maio de 2012
Ultima resposta 6 de mai. de 2012
Respostas 9
Participantes 2