[java] Applet Problem! Help!!

Started by
1 comment, last by Glass_Knife 18 years, 8 months ago
HI everyone I am having a wierd problem with my pc and applets. Ok here is a sample small applet program:BigDebtApplet.java (//am using this small applet to save space on the post.) package Hour13 import java.awt.*; public class BigDebtApplet extends java.applet.Applet { int debt; public void init(){ debt=59000000; debt=debt/1440; } public void paint(Graphics screen){ screen.drawString("A minute's worth of debt is $" + debt, 5, 50); } } And here is a simple html code I am using: BigDebtApplet.html <applet code="BigDebtApplet.class" height=150 width=300> Now I take out the package declaration, save the code to jedit or notepad, in my jdk1.5_04\bin directory, compile manually with console/javac, run the html in either Firefox or IE with suns VM, it shows in the browser, but not using appletviewer it just gives my a blank space in the console like I was compiling the code. But if I use the code that any IDE creates(IDEAJ is my main program) it comes up java applet failed. Now if I copy that to the bin dir it fails as well. It runs fine using IntelliJ Idea 5.0's built in applet viewer. I have even tried to use DreamWeavermx 2004 for automatic code and path creation on my intellij created applets to make an html file and that fails as well. Is there a way I can run an applet that is not in the jdk\bin directory? And how can I run an applet created by my IDE? Also is the jdk appletviewer supposed to work like that? I thought I used it before and it worked fine, not anymore. Any help would be apprectiated I would like to be able to run my own applets off the harddrive with having to copy the code and manually compile in the jdk\bin directory. Sorry if any of this is confusing. You think my Jdk/jre is corrupted? or the appletveier?
Advertisement
Try placing the applet in the default package instead of Hour13. If that works, read up on packages.
Here is a link to the Applet TAG

If you want to run the applet, and the code is in another place, use the codebase tag...
<applet codebase="bin" code="applet.class"></applet>

I have had trouble with some browsers by using the short form of the tag, such as <applet code="app.class"/>. I always put the ending tag.

NOTE: If you put the applet in a package, then you need the packagename with the class.
<applet code="mypackage.MyApplet.class"></applet>

If you want to run the applet, you can always put it in a jar file. Then you need the jar file with the index.html page. Then you need to add the archive tag to the applet tag.

<applet codebase="res/java" code="Hour13.BigDebtApplet.class"
archive="bigapp.jar"></applet>

The code could be in a jar file called bigapp, and located in the res/jara folder.

Hope that helps

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

This topic is closed to new replies.

Advertisement