在线等答案:java.lang.ClassNotFoundException:

按书上的小例子做的,可是却出现问题,首先是文件showmsg.javaimportjava.awt.*;importjava.applet.*;pulicclasssho... 按书上的小例子做的,可是却出现问题,
首先是文件showmsg.java
import java.awt.*;
import java.applet.*;
pulic class showmsg extends Applet
{
String msg1,msg2,msg3;
public void init()
{
msg1=getParameter("msg1");
msg2=getParameter("msg2");
msg3=getParameter("msg3");
}
public void paint(Graphics g)
{
Font font = new Font("SanSerif",Font.BOLD,30);
g.getFont(font);
g.setColor(Color.blue);
g.drawString(msg1,20,40);
g.drawString(msg2,20,70);
g.drawString(msg3,20,100);
}
}
然后是usingPlugin.jsp文件
<%@page contentType="text/html" %>
<%@page pageEncoding="GB2312" import="java.awt.*,java.applet.*" %>
<html>
<head>
<title>演示 plugin</title>
</head>
<body>
<jsp:plugin type="applet" code="showmsg.class" height="200" width="200">
<jsp:params>
<jsp:param name="msg1" value="C++" />
<jsp:param name="msg2" value="Java" />
<jsp:param name="msg3" value="C#" />
</jsp:params>
</jsp:plugin>
</body>
</html>
tomcat完全没问题,在IE里输入http://localhost:8080/usingPlugin.jsp后出错,提示如下:

载入:找不到类 showmsg.class。
java.lang.ClassNotFoundException: showmsg.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/showmsg/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
异常:java.lang.ClassNotFoundException: showmsg.class
载入:找不到类 showmsg.class。
java.lang.ClassNotFoundException: showmsg.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/showmsg/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
异常:java.lang.ClassNotFoundException: showmsg.class
求高手请教
展开
 我来答
tianjigeng
2010-05-21 · TA获得超过593个赞
知道小有建树答主
回答量:387
采纳率:0%
帮助的人:0
展开全部
编译后的class文件和jsp文件不在一个目录下。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式