Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

When i run it i get an error saying Exception in thread "main"

  Asked By: Lydia    Date: Oct 31    Category: Java    Views: 709
  

This was the program i had written
import java.io.*;
class Employee
{
float sal;
float ta;
float ra;
}
class EmployoeeDemo
{
public static void main(String args[])
{
Employee e = new Employee();
float ansal;
e.sal= 5000;
e.ta= 200;
e.ra= 400;
ansal= (e.sal+e.ta+e.ra) *12;
System.out.println("Annual salary is" + ansal);

}
}
When i run it i get an error saying Exception in thread "main"
what does this mean.
where am i going wrong?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Dinh Tran     Answered On: Oct 31

you have not declared the employee class  as a public method...example

public static main  Employee {
.
.
thats why you are having this error,theres no main method declared in ur
program...the program  wouldnt compile

 
Answer #2    Answered By: Ann Evans     Answered On: Oct 31

if you are using MS-Dos prompt to compile and execute your program
You need to add tools.jar itself to the classpath, not just the directory it
is in, in your system environment.

set classpath="c:\jdk\lib"
where jdk is directory where jsdk is installed.

Or

download the edition of java  "JCreator" from www.jcreator.com
It is free, install it , it automatically fix the classpath in its own
environment.

Or

Go through the link
forum.java.sun.com/thread.jsp

 




Tagged: