File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes A Basic Simple Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "A Basic Simple Problem" Watch "A Basic Simple Problem" New topic
Author

A Basic Simple Problem

Gary Farms
Ranch Hand

Joined: Jun 24, 2000
Posts: 57
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
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
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
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??


------------------
Vikas Aggarwal
Technology Associate
http://www.vikinsa.com


Vikas Aggarwal<BR>Technology Associate<BR>http://www.vikinsa.com
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A Basic Simple Problem
 
Similar Threads
why public keyword is necessory here?
basic questin
Noob needs help with Hello World
write to a file without delete it (noob question)
A Basic Question