Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Selection does not contain a main type error.
Selection does not contain a main type error. [message #820382] Tue, 13 March 2012 23:47 Go to next message
Kevin Crawford is currently offline Kevin Crawford
Messages: 1
Registered: March 2012
Junior Member
I am currently doing a Java course. I am only 3 lessons in. When I run the TestTax class (I right click on TestTax.java and run as a java application), I get an error that says "Selection does not contain a main type". If I click the green "run" button, it says "Editor does not contain a main type." As you can see from the code below, it does have a main method. Am I missing something??

class TestTax{
public static void main(String[] args){

NJTax t = new NJTax(); // creating an instance

t.grossIncome= 50000; // assigning the values
t.dependents= 2;
t.state= "NJ";

double yourTax = t.calcTax(); //calculating tax

// Printing the result
System.out.println("Your tax is " + yourTax);
}
}
Re: Selection does not contain a main type error. [message #822553 is a reply to message #820382] Fri, 16 March 2012 15:24 Go to previous message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2234
Registered: July 2009
Senior Member
On 3/13/2012 11:47 PM, Kevin Crawford wrote:
> I am currently doing a Java course. I am only 3 lessons in. When I run
> the TestTax class (I right click on TestTax.java and run as a java
> application), I get an error that says "Selection does not contain a
> main type". If I click the green "run" button, it says "Editor does not
> contain a main type." As you can see from the code below, it does have a
> main method. Am I missing something??
> class TestTax{
> public static void main(String[] args){
>
> NJTax t = new NJTax(); // creating an instance
>
> t.grossIncome= 50000; // assigning the values
> t.dependents= 2;
> t.state= "NJ";
>
> double yourTax = t.calcTax(); //calculating tax
>
> // Printing the result
> System.out.println("Your tax is " + yourTax);
> }
> }

What kind of project is it in? It should be a Java Project. The source
file should also be in a Source Folder in the project's Java Build Path.
I'd also suggest not using the "default" package.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:Text Compare Colors
Next Topic:Where can I download PyDev
Goto Forum:
  


Current Time: Wed Jul 23 18:21:51 EDT 2014

Powered by FUDForum. Page generated in 0.01487 seconds