i am facing a prob while compiling a java prog.

India
May 8, 2009 12:45pm CST
it is saying "main" classnot found error:classname all are correct but what is happenning if i write the below code at that time also it says the same error or it says all lines are mistache in prog.tell me what is the error. import java.io.*; public class Hello { public static void main(String[] args)throws IOException { System.out.println("Hello java in mylot"); } } this is the prog can u tell me where is the error.i saved this with Hello.java
5 responses
@hugodc (26)
• Mexico
9 May 09
I compiled your program, and it works fine!. I just copied that code in a new file called Hello.java, then I compile on the command line with: javac Hello.java, then I ran your program with: java Hello
• India
9 May 09
i did the same thing but it is not working .It is showing the error is "Exception in thread "main" java.lang.NoClassDefFoundError: Hello" .what can i do i can't understand.this prob arises from two days and i reinstalled my java software.then also not working..and did pathsetting also for uservariables and systemvariables ...
@hugodc (26)
• Mexico
10 May 09
When you compile your code... do you get a file called Hello.class ? I think your system configuration, and you java compiler are ok. That problem is because the Java Virtual Machine don't find the .class file or the .class file don't contain a class called Hello, Java is case sensitive, try typing correctly all the words and commands. THat's all what I think could be wrong.
9 May 09
well, there really shouldnt be any error, are u using a text editor like text pad, or net beans enviromet. if it gives you that message it might be a typographical error. really common. re check the name of the class again. Also try creating another method whci does the printing, and remove then call it in the main. I am a bit tired cos ui have been working, i will check it later on and give u a feedback. if u solve it before then, let me know ok.i am sure its a little mistake
• India
9 May 09
ok thanks ..pls tell me after where is the problem is the software of the system problem may be...what is that..
@janwen (41)
• China
4 Jun 09
this is no syntax error,how do you compile your program,use javac command through command line of your os,if this,but you know,if you java Hello,you must set the classpath,if you ide like netbeans,eclipse,you neednot to set classpath!try it
@bulzika (279)
• Dominican Republic
5 Jul 09
try writing capital M in main
• India
13 Jul 09
try again by removing import statement and also removing throws IOException since it is a simple java prog leave the exception.so d prog u must try is class Hello {public static void main(String [] args) {System.out.println("Hello Java"); } }