.jar-Datei gibt mir immer "could not find main class". Programm wird beendet

Ich habe Probleme mit diesem sowohl netbeans und eclipse auch mit einer einfachen Datei, zeigt ein jframe mit einem jlabel auf. Mein netbeans-Projekt-Eigenschaften klar definiert testing2.hihi, wie meine Main Klasse und ich habe saubere und bauen es erzeugt einen .jar-Datei in mein dist-Ordner. Wenn ich doppelt drauf klicken, es gibt mir die Meldung" could not find main class. Programm wird beendet." Allerdings, wenn ich wählen, führen Sie es von der Eingabeaufforderung aus mit "java-jar hello2.jar" es wird laufen wie normal!

Dies ist die manifest-Datei innerhalb der .jar-Datei.

      Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_04-b20 (Oracle Corporation)
Class-Path: 
X-COMMENT: src/hihi
Main-Class: testing2.hihi



package testing2;

public class hihi extends javax.swing.JFrame {

/**
 * Creates new form hihi
 */
public hihi() {
    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() {

    jLabel1 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jLabel1.setText("hihi");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(50, 50, 50)
            .addComponent(jLabel1)
            .addContainerGap(334, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(33, 33, 33)
            .addComponent(jLabel1)
            .addContainerGap(253, Short.MAX_VALUE))
    );

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

/**
 * @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(hihi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(hihi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(hihi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(hihi.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 hihi().setVisible(true);
        }
    });
}
//Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
//End of variables declaration
}
Was macht Ihr manifest-Datei Aussehen? Geben Sie eine main-Klasse?
Klingt wie die shell-Regel für die Ausführung .jar-Dateien werden möglicherweise geschlafen. Auf welchem Betriebssystem laufen Sie?
Hopp ich bin mit windows vista.Darf ich wissen, die manifest-Datei beziehen Sie sich? das innerhalb der .Glas, oder der einen innerhalb des Projekt-Hauptverzeichnisses( sorry,ich bin noch ein Anfänger auf diesem). Anyways ich bin mit netbeans und ich angegeben haben, die main-Klasse zu werden testing2.hihi, die unter der Registerkarte ausführen der Projekt-Eigenschaften. Vielen Dank für Ihre Hilfe!
Letztlich, es ist das manifest in der JAR, die Fragen ... wenn Sie sich beim ausführen der JAR. Haben Sie es angeschaut, um zu überprüfen, dass es korrekt ist?
hi ich habe in der manifest-Dateien in meinen code-block oben. Es scheint mächtig gut zu mir. Gibt es etwas falsch mit ihm?

InformationsquelleAutor Laughy | 2012-06-04

Schreibe einen Kommentar