Whenever I try to run a code in eclipse it asks me to run it through ant build and when I do it it does not work.
I have the same problem sometimes. I think it means that whatever file you're trying to run is not a valid class and won't run it. What works for me is making a new class and copying my work into the new class.
A couple possibilities:
I'm thinking that it might have something to do with if you say yes to "create modules" or whatever when eclipse asks you that when you first create a new class