bugwheels94
bugwheels94

Reputation: 31940

Jframe Program giving NoClassDefFoundError on run

My Code

import java.awt.*; 
 import javax.swing.*; 

 // Create a simple GUI window
 public class TopLevelWindow {

    private static void createWindow() {

       //Create and set up the window. 
       JFrame frame = new JFrame("Simple GUI");
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

       JLabel textLabel = new JLabel("I'm a label in the window",SwingConstants.CENTER); 
       textLabel.setPreferredSize(new Dimension(300, 100)); 
       frame.getContentPane().add(textLabel, BorderLayout.CENTER); 

       //Display the window. 
       frame.setLocationRelativeTo(null); 
       frame.pack();
       frame.setVisible(true); 
    }

    public static void main(String[] args) {

       createWindow();

    }
 } 

And how i run the program with the exceptions are enter image description here

Upvotes: 0

Views: 77

Answers (1)

Reimeus
Reimeus

Reputation: 159844

Use . rather than / to specify the fully qualified class name when using java

java java1.TopLevelWindow 

Also add a package declaration:

package java1;

Upvotes: 4

Related Questions