注册 登录
编程论坛 J2EE论坛

求助!jsp运行错误

寒宵 发布于 2007-12-04 01:51, 1219 次点击
通过javac编译
但运行java myclass时出现
Exception   in   thread   "main"   java.lang.noclassdefoundError:myclass
8 回复
#2
风月_无边2007-12-04 14:44
main()方法出錯﹗
#3
StarScar2007-12-04 17:46
java.lang.noclassdefoundError:myclass
找不到myclass.class这个类文件
#4
风雪狼心2007-12-04 18:27
程序不发上来,怎么看?
#5
寒宵2007-12-04 20:07
package

import javax.servlet.*;
import javax.servlet.http.*;
import *;

public class HelloServlet extends HttpServlet {
    
    //Initialize global variables  
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }
    
    //Process the HTTP Get request  
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        response.setContentType("text/html;charset=GB2312");
        PrintWriter out = response.getWriter();
        
        out.println("<html>");
        out.println("<head><title>CH2 - HelloServlet</title></head>");
        out.println("<body>");
        out.println(" Hello World <br>");
        out.println("大家好");
        out.println("</body>");
        out.println("</html>");

        out.close();
    }
    
    //Get Servlet information
    public String getServletInfo() {
        return " Information";
    }
}

初学照着书上的方法运行的!还是不好用!
#6
风雪狼心2007-12-04 21:45
这个程序可以用“java”来运行吗?我觉得不可以吧,java命令似乎只可以运行有main方法的程序,这是个servlet要放在服务器里执行
不知道我说的对不对
#7
zhangkangl2007-12-05 15:46
我觉得也是,你这个程序只是继承了HttpServlet类,应该是不能够直接运行的,他应该需要一个web服务器来运行,比如tomat

[[italic] 本帖最后由 zhangkangl 于 2007-12-5 15:47 编辑 [/italic]]
#8
scdmike2007-12-05 15:53
这是个Servlet,不能用java运行。放到服务器下。
#9
sea72007-12-07 19:08
同意楼上的
1