Newsgroup: it.comp.java
Titolo: Non trova la classe main

Ciao a tutti, non riesco a far partire nessuna applicazione compilata. e con
il comando java ne javaw. Mi dice sempre che manca la classe main, ma
chiaramente c'è!
Se invece eseguo il programma da un ambiente tipo netbeans funziona
perfettamente. Ho provato pure le app di esempio e nemmeno quelle partono,
come posso fare?

 come posso fare?
Se ci dici che errore ti da', magari ti possiamo aiutare...cosi' al buio
e' un po' difficile...per me potrebbe essere colpa delle lune di
Saturno...piu' probabilmente qualche pasticcio con il CLASSPATH. :-)
-- 
Lucio Benfante
Java User Group Padova: 
http://www.jugpadova.it
Brainbench MVP for Java 1: 
http://www.brainbench.com
MyTranscript: 
http://www.brainbench.com/transcript.jsp?pid=167064


é un'app che non ha bisogno del classpath, è una semplice finestra con qlc
bottone, è solo una prova.
Se la lancio da dentro Netbeans va, se la compilo e la eseguo con "Javaw
nome_app" da errore: Could not find the main class. Program will exit.



...ma che JVM stai usando?...mai visto un errore del genere con quella Sun.
Prova a dare il comando:
java -version
Hai impostato correttamente il PATH? Il file nome_app.class c'e'? Magari
posta anche il codice.



La versione è la 1.4.1_01 standard edition
questo è il codice, ma è solo un piccolo esempio... l'errore me lo da con
tutte le app che provo a far partire, e sono tutte app che funzionano
perfettamente x' in fase di debug vanno benissimo...
package prova;
/**
 *
 * @author  Nicolò
 */
public class prova extends javax.swing.JFrame {
    /** Creates new form prova */
    public prova() {
        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.
     */
    private void initComponents() {
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jDialog1 = new javax.swing.JDialog();
        jLabel1 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jTextArea1 = new javax.swing.JTextArea();
        jCheckBox1 = new javax.swing.JCheckBox();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jButton2 = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        jRadioButtonMenuItem1 = new javax.swing.JRadioButtonMenuItem();
        jRadioButtonMenuItem2 = new javax.swing.JRadioButtonMenuItem();
        jDialog1.getContentPane().setLayout(null);
        jLabel1.setFont(new java.awt.Font("Dialog", 1, 36));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("CAZZONE");
        jLabel1.setToolTipText("Si... sei un CAZZONE!");
        jDialog1.getContentPane().add(jLabel1);
        jLabel1.setBounds(120, 50, 200, 240);
        jButton3.setText("jButton3");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jDialog1.getContentPane().add(jButton3);
        jButton3.setBounds(0, 0, 81, 26);
        getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());
        setTitle("Prova del CAZZO");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(40, 70, 150, 100));
        getContentPane().add(jTextArea1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 180, 30));
        jCheckBox1.setText("jCheckBox1");
        getContentPane().add(jCheckBox1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(100, 190, 100, -1));
        jRadioButton1.setText("jRadioButton1");
        buttonGroup1.add(jRadioButton1);
        jRadioButton1.addActionListener(new java.awt.event.ActionListener()
{
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jRadioButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(10, 210, 130, 50));
        jRadioButton2.setText("jRadioButton2");
        buttonGroup1.add(jRadioButton2);
        getContentPane().add(jRadioButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(20, 250, -1, 40));
        jButton2.setText("jButton2");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(250, 20, -1, -1));
        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
        getContentPane().add(jSeparator3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(220, 0, 20, 310));
        jMenu1.setText("File");
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });
        jMenuItem1.setText("exit");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);
        jMenu1.add(jSeparator1);
        jCheckBoxMenuItem1.setSelected(true);
        jCheckBoxMenuItem1.setText("Acceso");
        jCheckBoxMenuItem1.setToolTipText("Provami");
        jCheckBoxMenuItem1.addActionListener(new
java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jCheckBoxMenuItem1);
        jMenu1.add(jSeparator2);
        jRadioButtonMenuItem1.setText("RadioButton");
        buttonGroup2.add(jRadioButtonMenuItem1);
        jMenu1.add(jRadioButtonMenuItem1);
        jRadioButtonMenuItem2.setText("RadioButton");
        buttonGroup2.add(jRadioButtonMenuItem2);
        jMenu1.add(jRadioButtonMenuItem2);
        jMenuBar1.add(jMenu1);
        setJMenuBar(jMenuBar1);
        java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-449)/2, (screenSize.height-342)/2, 449,
342);
    }
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
        jDialog1.dispose();
    }
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
        jDialog1.show();
    }
    private void
jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
        if (jCheckBoxMenuItem1.isSelected())
            jTextArea1.setText("Acceso");
        else
            jTextArea1.setText("Spento");
    }
    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent
evt) {
        // Add your handling code here:
    }
    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        if (jCheckBox1.isSelected())
        {
            String str;
            if (jRadioButton1.isSelected())
                str=jRadioButton1.getLabel();
            else if (jRadioButton2.isSelected())
                str=jRadioButton2.getLabel();
            else
                str="Nulla...";
            jTextArea1.setText(str);
            jCheckBox1.setSelected(false);
        }
        else
            jTextArea1.setText("");
    }
    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
        System.exit(0);
    }
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new prova().show();
    }
    // Variables declaration - do not modify
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItem1;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItem2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration
}

1. Avvia un prompt dei comandi e mettiti nella directory dove hai il
 sorgente prova.java
2. Se in quella directory c'e' il file prova.class, eliminalo cosi'
non rischia di fare confusione.
2. Compila dando il comando:
javac -d . prova.java
3. Senza spostarti da quella directory, esegui dando il comando:
java -classpath . prova.prova
...per la spiegazione sul perche' cosi' dovrebbe funzionare, guarda qui:
http://java.sun.com/docs/books/tutorial/java/interpack/managingfiles.html
