This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling applet which loads JasperPrint from jsp  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a similar problem which many are facing. I tried my best but I'm not able to solve it.

I have an applet class


public class AppletTrial extends JApplet{

public void getviewer(JasperPrint jasprint){
//JasperPrint jasprint = (JasperPrint)request.getAttribute("jasprint");
JRViewer aViewer = new JRViewer(jasprint);
JFrame aFrame = new JFrame("Report Viewer");
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
aFrame.setSize(screenSize.width/2, screenSize.height/2);
java.awt.Insets insets = aFrame.getInsets();
aFrame.setSize(aFrame.getWidth() + insets.left + insets.right, aFrame.getHeight() + + insets.bottom + 20);

this works fine. I want to call this same file in jsp(D:\workspace\projectName\web\reports\reports.jsp) using

<jsp:plugin type="applet" codebase="D:\workspace\projectName\build\web\WEB-INF\classes\in\support\reports" code="AppletTrial"
width="400" height="400">
<p>Unable to load applet</p>

Java Console gives me the following error:

java.lang.NoClassDefFoundError: AppletTrial (wrong name: in/support/reports/AppletTrial)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
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$ Source)
at Source)
Exception: java.lang.NoClassDefFoundError: AppletTrial (wrong name: in/support/reports/AppletTrial)

Kindly help me. I really need help

Posts: 42975
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The codebase attribute should not contain the directories that make up the package hierarchy; in this case it should be "D:\workspace\projectName\build\web\WEB-INF\classes".

I strongly recommend that you don't use absolute paths in this attribute, and also that you get into the habit of putting applet files outside of WEB-INF; otherwise this will only work on your local machine, but not anywhere else.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!