Results 1 to 2 of 2
  1. #1
    ziraell is offline Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Default Java Applet Loading

    Hello,

    I am learning how to embed Java applet into my application, but I am getting java.lang.ClassNotFoundException: jakub.MyApplet.class.

    I use Tomcat and Netbeans 7. Folder structure from Netbeans here:

    Java Applet Loading-screen-shot-2013-02-10-8.41.51-pm.jpg

    plugin.jsp file:

    Java Code:
    <%@page language="java" contentType="text/html"%>
    <html>
        <head>
            <title>Action: plugin</title>
        </head>
        <body>
            <jsp:plugin type="applet" code="jakub.MyApplet.class" codebase="/first_app" height="100" width="100">
                <jsp:params>
                    <jsp:param name="line" value="Well said!"/>
                </jsp:params>
                <jsp:fallback>Unable to start plugin</jsp:fallback>
            </jsp:plugin>
        </body>
    </html>
    MyApplet.java

    Java Code:
    package jakub;
    
    import java.applet.*;
    import java.awt.*;
    
    public class MyApplet extends Applet {
    
        String line;
    
        @Override
        public void init() {
            line = getParameter("line");
        }
    
        @Override
        public void paint(Graphics page) {
            page.setColor(Color.red);
            page.fillRect(0, 0, 50, 50);
            page.setColor(Color.green);
            page.fillRect(50, 0, 50, 50);
            page.setColor(Color.blue);
            page.fillRect(0, 50, 50, 50);
            page.setColor(Color.yellow);
            page.fillRect(50, 50, 50, 50);
            page.setColor(Color.black);
            page.drawString(line, 10, 40);
        }
    }
    Thanks for any help!

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,814
    Rep Power
    25

    Default Re: Java Applet Loading

    java.lang.ClassNotFoundException: jakub.MyApplet.class.
    The class name in the error message looks like a filename (ends with .class) class names do not include: .class
    The classname is: jakub.MyApplet so use that in the code= attribute

    what folders are the html file and the .class files in? The .class file should be in the jakub folder.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Java Applet Strange Image Loading Problem
    By 1yuchen in forum Java Applets
    Replies: 36
    Last Post: 01-06-2012, 03:06 AM
  2. problem loading XML file in java applet
    By lana in forum Java Applets
    Replies: 1
    Last Post: 11-24-2011, 05:12 PM
  3. Replies: 12
    Last Post: 04-14-2011, 02:58 PM
  4. Replies: 0
    Last Post: 07-29-2008, 02:19 PM
  5. Java Applet loading bar
    By genette in forum Java Applets
    Replies: 2
    Last Post: 12-27-2007, 04:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •