
菜鸟求:java servlet运行错误java.lang.NoSuchMethodError: main Exception in thread "main" ,如何改?
程序原文:importjava.io.*;importjavax.servlet.*;importjavax.servlet.http.*;publicclassHell...
程序原文:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><title>");
out.println("This is my first Servlet");
out.println("</title></head><body>");
out.println("<h1>Hello,World!</h1>");
out.println("</body></html>");
}
}
我用的UltraEdit,编译没错误,运行出现“java.lang.NoSuchMethodError: main Exception in thread "main" ,哪里出错了,怎么改呀各位大神? 展开
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><title>");
out.println("This is my first Servlet");
out.println("</title></head><body>");
out.println("<h1>Hello,World!</h1>");
out.println("</body></html>");
}
}
我用的UltraEdit,编译没错误,运行出现“java.lang.NoSuchMethodError: main Exception in thread "main" ,哪里出错了,怎么改呀各位大神? 展开
4个回答
展开全部
HttpServlet是j2ee技术不是j2se技术,需要将工程发布到java服务器,如tomcat下,通过浏览器去访问Servlet的地址,建议用MyEclipse开发j2ee项目
展开全部
提示没有main方法,你肯定是通过命令 java HelloWorld 来运行这个程序的吧, servlet不是直接可以运行的,需要在web容器中才能运行。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
UltraEdit是学习j2ee用的
javaweb应该用myeclips
你写的代码需要发布到服务器上运行。也可以下载tmocat服务器运行
——普科国际学生·神器AWM
javaweb应该用myeclips
你写的代码需要发布到服务器上运行。也可以下载tmocat服务器运行
——普科国际学生·神器AWM
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-12-11
展开全部
没有main方法啊!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询