Could not find the main class. Program will exit.

I am using eclipse. Followed is the code that I use, I get the error
---------------------------
Java Virtual Machine Launcher
---------------------------
Could not find the main class. Program will exit.
---------------------------
OK  
---------------------------
when I run it, what is the problem?

package myFolder;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class myClass extends HttpServlet {

      protected void doGet(HttpServletRequest request, HttpServletResponse response)
                  throws ServletException, IOException {
            response.setContentType("text/html");
            PrintWriter out=response.getWriter();
            out.println("reponse as HTML");
      }
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
                  throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request,response);
      }
public static void main(String args[]){}




}
LVL 9
william007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
you sure you're runn ing that class
do u right click it as select run>Run as application
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ManishLeadCommented:
I think ,
  servlet should not use main class. This is used in web application project.
U need to write jsp and servlet .
  If u want to create java class , then u can write main method .And call other method to do ur task.

U can directly call servlet ..but through url...

0
bloodredsunCommented:
This is a servlet so it does not have a main class. This means that you cannot run it as objects suggests but instead you need to run it inside a servlet container such as Tomcat.

You need to download and setup Tomcat from here http://tomcat.apache.org/  but don't worry it's very simple :-)
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

william007Author Commented:
Thanks,
This is due to the  run button is by default Run on a java file that I just deleted.
As before I thought that it is running the java files that are currently selected.
(Actually it is run on a file that we run before)
0
william007Author Commented:
And now it is running after I explicitly choose the file I want to run by clicking the Arrow just beside the run button. Thansk for the help again:-)
0
objectsCommented:
no probs :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.