éxecuter une classe qui contient une classe annonyme
salut tout le monde
je débute en java et j ai téléchargé un scripte qui affiche une fenêtre sur laquelle est écrit helloworld
ca compile sans problemes mais à l'execution ca genere une erreure de type java.lang.NoClassDefFoundError
j ai essayé avec supprimer la classe annonyme et ca a marché
maintenant je veux une explication à ca et je veux savoir comment executer cette classe sans avoir à supprimer la runnable
voici le code source d'origine
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| */import javax.swing.*;
public class HelloWorldSwing {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
} |
merci beaucoup