Josh Lewis
Josh Lewis

Reputation: 11

Java ClassNotFoundException html error

I need your helps once again. I have started programming with Java quite recently and I'm trying to create my first applet. I am just using the most basic code:

package firstofthings;

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

public class FirstApplet extends Applet {
    public void paint(Graphics g) {
        g.drawString("This is my first Java applet!", 20, 30);
    }
}

(The curly brackets are put in the right places, wont show up here in right place for some reason)

I am rather proficient in html, and I think it is the code in this container that is wrong, so if you could point me in the right direction that would be quite cool.

<!DOCTYPE html>
<html>
    <head>
        <title>FirstApplet</title>
    </head>
    <body>
        <applet
          codebase="."
          code="FirstApplet.class"
          name="FirstApplet"
          width="640"
          height="480"
          hspace="0"
          vspace="0"
          align="middle"
        >
        </applet>
    <body>
<html>

I took away the tags or else it wouldnt show up, so here is the details of the error I got

ClassNotFoundExeption

Java Plug-in 10.5.1.255
Using JRE version 1.7.0_11-b21 Java HotSpot(TM) Client VM
User home directory = C:\Users\Owner
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

Upvotes: 0

Views: 183

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

If firstapplet.html (the name of the HTML seen above) is actually at:

http://our.com/applet/firstapplet.html

Then the applet class (as loaded from a loose class file) must be located at:

http://our.com/applet/firstofthings/FirstApplet.class

If the class were in a Jar (highly recommended) or the codebase were set differently, it would change.

Upvotes: 1

Related Questions