whenever i try to run a java program . I get this error....
Exception in thread "main" java.lang.NoClassDefFoundError: main
Caused by: java.lang.ClassNotFoundException: main
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: main. Program will exit.
What could be possibly wrong ?
This is my program ...
class main{
public static void main(){
System.out.print("Hello, World");
}
}
3 replies to this topic
#1
Posted 16 June 2011 - 02:05 AM
|
|
|
#2
Posted 16 June 2011 - 02:57 AM
Why not try changing your class name to something different, like Hello?
#3
Posted 16 June 2011 - 04:34 PM
class main{
public static void main(){
System.out.print("Hello, World");
}
}
1: Is your java file named "main.java"?2: Have you tried using the correct form of main, which takes a String[] as an argument? Main without args doesn't work, it's just a method.
Wow I changed my sig!
#4
Posted 17 June 2011 - 03:13 AM
There is nothing wrong in this program ..
I ran this program finally using
"java -classpath . main" Command..
At last success..
I ran this program finally using
"java -classpath . main" Command..
At last success..
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









