What's wrong with this incredibly simple applet??? - Java
This is a discussion on What's wrong with this incredibly simple applet??? - Java ; I know this is supposed to be extremely simple but I have toiled for hours
over this and just cannot see what I am doing wrong. Can anyone point out
my mistake?
The environment is Java 6 Update 10 b25 ...
-
What's wrong with this incredibly simple applet???
I know this is supposed to be extremely simple but I have toiled for hours
over this and just cannot see what I am doing wrong. Can anyone point out
my mistake?
The environment is Java 6 Update 10 b25 on Windows Vista. I have a folder
D:\Test and in it I have 2 files namely applet.jar and applet.html. The
applet.jar contains one class namely MyApplet. The contents of the HTML
file are:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<applet code="MyApplet" archive="applet.jar" width="492"
height="280">
</applet>
</body>
</html>
As I said, all very simple. Now I am not concerned at this point what the
applet actually does - I just can't even get it to find it. When I run/open
the HTML file in any browser I get the following exception:
load: class MyApplet not found.
java.lang.ClassNotFoundException: MyApplet
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$AppletExecutionRunnable.run(Unknown
Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: D:\Test\MyApplet.class (The system
cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.http://www.protocol.file.FileURLConn...onnect(Unknown Source)
at sun.net.http://www.protocol.file.FileURLConn...Stream(Unknown
Source)
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: MyApplet
Why doesn't this work? I have tried adding ".class" the the code tag but
then it looks for MyApplet.class.class and I have tried putting the full
path to the applet.jar but the result is the same.
Anyone?
Cheers,
Karen (tearing her hair out!)
-
Re: What's wrong with this incredibly simple applet???
On Jun 21, 8:44 pm, "Karen Jenkins" <nob...@nowhere.com> wrote:
> I know this is supposed to be extremely simple ..
Applets are never very simple.
Why do you need an applet (as opposed to a frame)?
>..but I have toiled for hours
> over this and just cannot see what I am doing wrong. Can anyone point out
> my mistake?
What is the exact code of MyApplet?
Is it in a package?
Where in the applet.jar is the class located?
Did you check that last answer?
--
Andrew Thompson
http://pscode.org/
-
Re: What's wrong with this incredibly simple applet???
"Andrew Thompson" <andrewthommo@gmail.com> wrote in message
news:7726f66c-4c19-4ec4-b67e-96eaac341357@z24g2000prf.googlegroups.com...
> On Jun 21, 8:44 pm, "Karen Jenkins" <nob...@nowhere.com> wrote:
Thanks Andrew for trying to help.
>> I know this is supposed to be extremely simple ..
>
> Applets are never very simple.
I see.
> Why do you need an applet (as opposed to a frame)?
My boss needs me to do some work with applets so I am just trying to get the
most basic example to work.
>>..but I have toiled for hours
>> over this and just cannot see what I am doing wrong. Can anyone point out
>> my mistake?
>
> What is the exact code of MyApplet?
Unfortunately I am not allowed to post this but it shouldn't make any
difference in terms of just starting the applet itself should it? I'll
worry about getting the actual applet working when I have figured out how to
start it.
> Is it in a package?
No.
> Where in the applet.jar is the class located?
Just in the root directory.
> Did you check that last answer?
Yes, I renamed applet.jar to applet.zip and checked. It contains one
object: MyApplet.class in the root directory.
Any further ideas?
Karen
-
Re: What's wrong with this incredibly simple applet???
On Jun 21, 10:48 pm, "Karen Jenkins" <nob...@nowhere.com> wrote:
> "Andrew Thompson" <andrewtho...@gmail.com> wrote in message
...
> > What is the exact code of MyApplet?
>
> Unfortunately I am not allowed to post this but it shouldn't make any
> difference in terms of just starting the applet itself should it?
It will if the class is actually declared as
Myapplet rather than MyApplet (or possibly
other reasons).
> Any further ideas?
Post an SSCCE.
<http://pscode.org/sscce.html>
Note that I am *not* *asking* for 'your code',
but an SSCCE that fails in the way you describe.
--
Andrew Thompson
http://pscode.org/
-
Re: What's wrong with this incredibly simple applet???
Karen Jenkins wrote:
> Yes, I renamed applet.jar to applet.zip and checked.
FYI: no need to rename the file like that.
--
Lew
-
Re: What's wrong with this incredibly simple applet???
On Sat, 21 Jun 2008 20:44:39 +1000, "Karen Jenkins"
<nobody@nowhere.com> wrote, quoted or indirectly quoted someone who
said :
>Exception: java.lang.ClassNotFoundException: MyApplet
1. always put your classes in a package.
2. examine your jar file with jarlook.html to make sure all the pieces
you need are in there and properly named.
see http://mindprod.com/jgloss/products1.html#JARLOOK
3. Use winzip to extract the manifest and have a look at it. It
should have a main-class entry. See
http://mindprod.com/jgloss/jar.html
4. download one of my applets, something simply like the insult
generator. Look at the structure of its jars, source code, build
files etc, and slavishly copy the structure.
see http://mindprod.com/applet/applets.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com