I wrote a simple "Hello World " java program. It looks as follows: public class Welcome { public static void main String args[] ) { System.out.println("Hello World!" ); } } It compiles OK, but when I attempt to run it, I get an error stating: "Exception in thread "main" java.lang.NosuchMethodError: main Why am I getting this error??
Julia Reynolds
Ranch Hand
Joined: May 31, 2001
Posts: 123
posted
0
This is probably a classpath problem. On the command line before you type java HelloWorld, set the classpath to include the current directory like this: set classpath=%classpath%;. Don't leave out the dot at the end, that is the current directory symbol. Julia
sachin vyahalkar
Greenhorn
Joined: Jun 13, 2001
Posts: 2
posted
0
Check your classpath of java library and bin. It should be set as PATH = c:\jdk1.3\bin; SET CLASSPATH = C:\jdk1.3\lib; SET JAVA_HOME = C:\jdk1.3;
vikinsa
Ranch Hand
Joined: Apr 18, 2001
Posts: 46
posted
0
Hi!, There is an error in your program... public class Welcome { public static void main String args[] ) { System.out.println("Hello World!" ); } }
Should be
class Welcome { public static void main(String[] args) { System.out.println("Hello World!"); } }
You have forgot "(String[] args)"
Originally posted by Gary Farms: I wrote a simple "Hello World " java program. It looks as follows: public class Welcome { public static void main String args[] ) { System.out.println("Hello World!" ); } } It compiles OK, but when I attempt to run it, I get an error stating: "Exception in thread "main" java.lang.NosuchMethodError: main Why am I getting this error??
Vikinsa as much as I appreciate you unselfish help, your user name does not comply with the JavaRanch's naming policy. Pse change it you wish to continue posting in our forums. Thanks
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.