0

I have a strange and fustrating problem. I loaded all my .class files into a JAR file and placed it on my local web server. The problem is when I navigated to the page with my JAR I got a big ClassNotFoundExeption. I am 100% certian this class file is in my JAR. I also know the JAR file is in the same directory as my XHTML file

Here is the XHTML source

<html>
    <head>
    </head>
    <body bgcolor="000000">
        <center>
            <applet
                archive   = "program.jar"
                code    = "inigui4.class"
                width   = "500"
                height  = "300"
            >

            <param name="cache_option" value="no"> 
            </applet>
        </center>
    </body>
</html>

Very strange!

For some reason when I create a hello world applet I get the same problem (could it be with my LightTPD server?

Java source follows

import java.awt.*;
import java.applet.*;

public class inigui4 extends Applet {

    public void init() {
    }

    public void paint(Graphics g) {

        g.drawString("Welcome to Java!!", 50, 60 );

    }
}

Even stranger.

Now I can't load any applets on the web because I get this error. I will need to contact Oracle in the morning.

Roland Sams
  • 173
  • 1
  • 2
  • 12

3 Answers3

0

It can be caused by multiple reasons, but the most probable one is that you haven´t specified the package of the class you´re using. Look at the answer of this post.

Community
  • 1
  • 1
Luis Andrés García
  • 5,852
  • 10
  • 43
  • 57
0

If you are using packages you have have to prefix inigui4.class by its relative path into the jar

Aubin
  • 14,617
  • 9
  • 61
  • 84
  • Sorry for the stupid question but how can I do stack trace on the exception... I never really learned how to run stack traces – Roland Sams Nov 10 '12 at 09:33
0

I think the problem is here:

        <applet
            archive   = "program.jar"
            code    = "inigui4.class"
            width   = "500"
            height  = "300"
        >

Here, you specify inigui4.class - but in your Java code:

public class inigui_rb extends Applet {
   ...
}

This is inigui_rb. Try:

         <applet
            archive   = "program.jar"
            code    = "inigui_rb.class"
            width   = "500"
            height  = "300"
        >

The ClassNotFoundException should go away.

Also please adhere to the Java coding conventions when coding! In this case:

  • Class Names Begin With Capitals!
  • ClassNamesDoNotContainUnderscoresInsteadTheyAreCamelCased!
ppeterka
  • 20,583
  • 6
  • 63
  • 78