Now Place:2uzhan.com » Basic Java help

Basic Java help

Software Development @ July 7, 2008   Views:0

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?



Hmmm, strange problem,
If you are on windows, can u try first running the command set CLASSPATH= , and then trying to run the program in the same console after it.

Oh yes and please remember to wrap code in code tags

Set the CLASSPATH Variable to include also './'

This tell java to also regard the current directory to be our path of containing classes too.

I'm attempting to simplify my fundraising page, and would like to show exactly how much each donation would help us out. I've listed the options below, but I would like ...

Write a java program that asks a person for his height (in meters) and weight (in kilograms) and
outputs one of the messages: underweight, normal, or obese, using the BMI ...

Before I get into the specific issues, I want to provide some other details:

  • Normally, I work on a live, paid server (even in dev); I realize that is ...
© 2018 2uzhan.com Contact