新手求助!!
按照书上写的运行顺序程序如下
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";
}
}
运行javac HelloServlet.java没有问题
但运行java HelloServlet时出现 Exception in thread "main" java.lang.noclassdefoundErrorException in thread "main" java.lang.NoClassDefFoundError: HelloServlet (wrong name: tw/com/javaworld/CH2/HelloServlet)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at (URLClassLoader.java:260)
at (URLClassLoader.java:56)
at (URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at (URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
请高手指点!