Cannot start a swing from the command line

I use the command line on Windows to compile and then run my java programs. I went to http://java.sun.com/docs/books/tutorial/uiswing/start/compile.html and tried to compile the HelloWorldSwing.java class. it worked, but when I try java HelloWorldSwing, it gives me a bunch of erros and says something like Exception lines in the main stream java.lang.NoClassDefFoundError: HelloWorldSwing (wrong name: start / HelloWorldSwing)

I am trying to start java start / HelloWorldSwing and it says noClassDefFoundError. I am not getting errors with javac either. here is the code from the tutorial:

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 GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

EDIT: used by javaw

a popup will appear

"java error occurred"

another window

": . : jni, . "

- java-, - ? , ?

, .java .class.

, , .

EDIT2 /HelloWorldSwing HelloWorldSwing java.

javac. 2 , , javaw, java NoClassDefFoundException, ClassLoaders -.

EDIT3 , " "; . , ?

javaw , .

+5
7

. :

,

:

a) ( pacakge start;) ,

b) package start; -d javac .

, .

+2

java? HelloWorldSwing.class "start", . , . :

cd start
java HelloWorldSwing

EDIT: "package start;". ? , HelloWorldSwing "start"

java start.HelloWorldSwing

.

. .

+3

:

java HelloWorldSwing

java start/HelloWorldSwing

java- (javac) - ( start/HelloWorldSwing.java, , ), Java (java) - .

.class , start/HelloWorldSwing, (NoClassDefFoundError), : " , ).

, , .java .

+2

, , , Java,

javac HelloWorldSwing.java
java HelloWorldSwing
+1

, , , . :

package start;

Java . , "start" , "start" . , , HelloWorldSwing.class "start" :

java start.HelloWorldSwing
+1

:

import java.awt.*;

0

:

    javac HelloWorldSwing.java

:

    java -cp . HelloWorldSwing.java

.

0

All Articles