在线等答案: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
求高手请教 展开
首先是文件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
求高手请教 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询