General discussion

Locked

Simple applet won't run - please help

By MadestroITSolutions ·
Hi all,
I am an experienced programmer trying to learn Java. I have a very simple applet that I cannot get to run for some reason. Please see the code below:

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

public class BLinkJVerCheck extends Applet
{
private Label m_labVersionVendor;
public void init()
{
Color colFrameBackground = Color.pink;
this.setBackground(colFrameBackground);
m_labVersionVendor = new Label (" Java Version: " +
System.getProperty("java.version") +
" from "+System.getProperty("java.vendor"));
this.add(m_labVersionVendor);
}
}

As you can see, this a pretty simple, straight forward applet, but for some reason when I attempt to run it on a web page, I get the following error (when I put the mouse on top of the square the applet is supposed to draw):

load: class BLinkJVerCheck not found

The tag on the web page:
<APPLET height="60" alt="Browser has Java disabled" hspace="22" width="440" code="BLinkJVerCheck.class" />

The applet file IS sitting in the same folder as the web page that calls it. When I compile the applet, everything goes ok, I get no errors and the class file is generated.

Any ideas....???... I always found Java annoying, and now that I finally want to make the move, I cannot get a stupid applet to work... please HELP!

Thank you in advance!

This conversation is currently closed to new comments.

50 total posts (Page 1 of 5)   01 | 02 | 03 | 04 | 05   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Tony Hopkinson In reply to Simple applet won't run - ...

Not mad keen on Java myself.
Try this link
http://javaboutique.internet.com/tutorials/Java_by_Example/section1_1.html

Collapse -

by MadestroITSolutions In reply to

Thank you. A good source. Still not able to fix my problem though...

Collapse -

by Martin Simons In reply to Simple applet won't run - ...

If you are using Internet Explorer to view this
applet, you will probably need to compile this
using the option "-target 1.1". And, if you are
using jdk 1.5 (5.0) you will probably not be able
to use this option.

Collapse -

by MadestroITSolutions In reply to

Thank you for replying. Yes, I was not able to compile it with that option on 5.0
I did try it with 1.4.x though. The compiler yields no errors but the appletviewer does not launch and the applet does not load on the page.

Collapse -

by debfar In reply to Simple applet won't run - ...

I just copied your Java code then compiled it,
then I created a simple HTML page and pasted your applet tag into the page. And guess what?
It works just fine through my IE browser.

Here is what I have on my simple HTML page:
-----------------
<HTML>
<TITLE>Applet</TITLE>
<HEAD>Applet</HEAD>
<APPLET height="60" alt="Browser has Java disabled" hspace="22" width="440" code="BLinkJVerCheck.class" />

</HTML>
-----------------

Collapse -

by MadestroITSolutions In reply to

Thank you for your reply. I tried your tag but it still doesn't work. Must be something with compilation. Thanks again!

Collapse -

by Tarzanek In reply to Simple applet won't run - ...

Hi there,
actually your java code is OK along with the html page tag. I am running WINXP with JAVA5 installed & the applet made from your article was running fine. I suppose the problem is elsewhere. Probably bad instalation of JDK or browser plugin. Try setting CLASSPATH (mine is not set & still the applet works) or checking whether there couldn't be some browser related problems.

Collapse -

by MadestroITSolutions In reply to

Thank you for replying. I think the problem may be a conflict of installations. Please see other responses. Thank you!

Collapse -

by rafiq In reply to Simple applet won't run - ...

hi,
your code looks ok. Why not you first try out the applet using AppletViewer before trying in the browser.

hope this helps,

rgds,
Rafiq.

Collapse -

by MadestroITSolutions In reply to

Thank you for replying. I used the appletviewer and it doesn't do anything. The command line executes but the appletviewer does not start, so I imagine something is wrong with the compiled code. Although your answer put me in the right direction, it still didn't solve my problem. Your reply is very much appreciated, thanks again!.

Back to Web Development Forum
50 total posts (Page 1 of 5)   01 | 02 | 03 | 04 | 05   Next

Related Discussions

Related Forums