Program wont run due to exception in thread main

I am trying to run the below program and it wont work.

It compiled with no problem: javac Myfirst.java

Here is my attempt and error:

C:\Program Files\Java\jdk1.5.0_06\bin>java Myfirst

Exception in thread "main" java.lang.NoClassDefFoundError: Myfirst

The source code:

publicclass Myfirst

{

publicstaticvoid main(String[] args)

{

System.out.println("hi");

}

}

Message was edited by:

oaklandar

[790 byte] By [oaklandara] at [2007-11-26 14:53:31]
# 1
public class Myfirst{public Main() {public static void main(String[] args){System.out.println("hi");}}}Try this
ctopkellya at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks so much for your quick response.I did a search on this site and found this to work for me:java -cp . MyfirstAlthought I dont know why I had to do this to make it work?
oaklandara at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...
# 3
Read this: http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html
ChuckBinga at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...
# 4
No problem just trying to help out while i am waiting for my post to be answered.
ctopkellya at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...
# 5
I don't want to curb your enthusiasm Kelly, but you should not post answers unless you are 100% sure. I have been guilty of this myself. Try to compile your code and see what happens.
floundera at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...
# 6

Good Day Friend!

the code what you tried first is working fine

public class Myfirst

{

public static void main(String[] args)

{

System.out.println("hi");

}

}

D:\Program Files\Java\jdk1.5.0\bin\Balaji>javac Myfirst.java

D:\Program Files\Java\jdk1.5.0\bin\Balaji>java Myfirst

hi

vasu_gba at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...
# 7
Hey vasuIf you had read more clearly, there was nothing wrong with the code. He hadn't set his classpath correctly. Not to mention that the problem was solved several hours ago.
floundera at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...
# 8
sorry about the information i gave but i was only trying to bounce things off the guys head.That code worked on my computer in NetBeans.
ctopkellya at 2007-7-8 8:41:52 > top of Java-index,Java Essentials,New To Java...