J2EEGeneral J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I am trying to do a simple beginners applet (HelloWorld) with the following code:
import java.applet.*;
import java.awt.*;
/**
* The HelloWorld class implements an applet that
* simply displays "Hello World!".
*/
public class HelloWorld extends Applet {
public void paint (Graphics g) {
//Display "Hello World!"
g.drawString("Hello World!", 50, 25);
}
}
This will compile fine into HelloWorld.class. But when I try to include it into a HTML file:
<html>
<head>
<title>A Simple Program</title>
</head>
<body>
Here is the output of my program:
<applet code="HelloWorld.class" width="150" height="25">
</applet>
</body>
</html>
When I view the file in a browser, the browser says it can't find the class file. Can someone help me to figure out what I'm doing wrong? As I said, I'm a true beginner in the Java world, especially with applets. Any help would be very much appreciated
I am using IE 6.0 on a Windows 98 machine. Every time I bring the html file into a browser, I get a message on the bottom toolbar saying that it can't find the class file.
Sounds like the .class and .htm aren't in the same directory.
I think I have a different applet issue. I am developing in jdk1.4 and my company has some other applets that require earlier versions. IE 6.0 seems to require me to check/uncheck java 1.4 in my Internet Options and restart IE to switch between applets. Per Horton's Java 2, I tried using autodownload to manage it. I also tried some code off of SUN's autodownload site. Unfortunately, neither succeeded. I also tried loosening my security settings, but even if that worked, I wouldn't want to tell my clients to do that. How can one specify the version of JRE the browser should use? TIA.
All my files (HTML, class, and java) are in the same directory. No matter what I try, I can't get the html to display the applet. This is true even for the samples. I tried updating the autoexec file, but it doesn't seem to help.