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.
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:
<jsp:plugin
type="applet"
code="jTwain.JTwainUI"
codebase="/YourApplicationContext/applet"
width="600" height="500">
</jsp:plugin>
精彩评论