JSP 类中的 JApplet 未找到
我意识到类似的问题已经在这里得到了解答,但我在这里真的很挣扎,因为这是我必须制作的第一个 Japplet。
基本上我在尝试嵌入我的测试 Japplet 时遇到类未找到异常:
public class JTwainUI extends JApplet{
public void init ()
{
JFrame frame = new JFrame();
frame.setSize(new Dimension(800, 600));
frame.setLayout(new GridLayout(6, 0));
panel = new JPanel();
button = new JButton("upload from scanner");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
initScan();
}
});
panel.add(button);
frame.add(panel);
this.add(frame);
this.repaint();
this.setVisible(true);
}
在 myjsp 页面中:
<jsp:plugin
type="applet"
code="JTwainUI.class"
codebase="jTwain.JTwainUI"
width="600" height="500">
</jsp:plugin>
我的 java 类位于:WEB-INF\classes\jTwain
我真的不明白发生了什么,如何找不到类 ps我尝试将代码库编写为 WEB-INF.classes.jTwain 等,我的 java 版本应该没问题,因为 suns 网站上的小程序工作正常。
I realsie that similar questions have been answered here about this problem but im really struggling here as this is the first Japplet i have had to make.
Basically im getting a class not found exception when trying to embed my test Japplet:
public class JTwainUI extends JApplet{
public void init ()
{
JFrame frame = new JFrame();
frame.setSize(new Dimension(800, 600));
frame.setLayout(new GridLayout(6, 0));
panel = new JPanel();
button = new JButton("upload from scanner");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
initScan();
}
});
panel.add(button);
frame.add(panel);
this.add(frame);
this.repaint();
this.setVisible(true);
}
in myjsp page:
<jsp:plugin
type="applet"
code="JTwainUI.class"
codebase="jTwain.JTwainUI"
width="600" height="500">
</jsp:plugin>
where my java class is in: WEB-INF\classes\jTwain
I really dont understand whats going on, how can the class not be found p.s. ive tried doing the code base as WEB-INF.classes.jTwain etc and my java version should be fine because the applets on suns website work fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/WEB-INF/classes 目录在客户端资源管理器 java 环境(小程序运行的位置)中不可见,因此当它尝试加载您的类时,它无法找到它。
也许我对(非常)类似问题的回答可以帮助您。
编辑:假设您已将类保存在可访问的目录中(在名为 /applet 的文件夹中),您的代码应如下所示:
The /WEB-INF/classes dir is not visible from the client explorer java environment (which is where the applet is run), so when it's trying to load your class, it can't found it.
Maybe my answer to a (quite) similar question can help you.
Edit: suposing you have saved your class in an accesible dir (in a folder called /applet), your code should look something like this: