I am trying to just compile a very back program and it compiles but when I run it I get errors:
Java version = java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Server VM (build 1.5.0_09-b03, mixed mode)
Program HelloJava.java
public class HelloJava {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
or import javax.swing.*;
public class HelloJava
{
public static void main( String[] args )
{
JFrame frame = new JFrame( "Hello, Java!" );
JLabel label = new JLabel("Hello, Java!", JLabel.CENTER );
frame.add ( label );
frame.setSize( 300, 300 );
frame.setVisible( true );
}
}
After I compile and run either program above which appear to be correct (no compile errors) I get the following:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloJava
I used to be able to do this sort of program (v1.4?) and did not have any problems.
Can anyone assist or suggest what I am doing wrong?
Thanks.