Jump to content

Unable to run Java Programs.

- - - - -

  • Please log in to reply
3 replies to this topic

#1
sakthig

sakthig

    Newbie

  • Members
  • Pip
  • 8 posts
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");

}

}

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Why not try changing your class name to something different, like Hello?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
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
sakthig

sakthig

    Newbie

  • Members
  • Pip
  • 8 posts
There is nothing wrong in this program ..
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