Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2003, 12:32 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginner needs help with Applets

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
 
Old August 23rd, 2003, 01:31 AM
Authorized User
 
Join Date: May 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
This code works fine i checked it on IE 5. which browser u are using and what's the OS u r working on.

Regards


Yashraj Chauhan
Java\J2EE Specialist
Wiley Support Team
 
Old August 23rd, 2003, 09:56 AM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old August 26th, 2003, 06:51 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

- Ed

 
Old August 27th, 2003, 12:54 AM
Authorized User
 
Join Date: May 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Ya make sure that u'r class file and the HTML file are in same directory.

Regards

Yashraj Chauhan
Java\J2EE Specialist
Wiley Support Team
 
Old August 27th, 2003, 12:32 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Chris





Similar Threads
Thread Thread Starter Forum Replies Last Post
No more Java Applets for me... larry Javascript 0 January 10th, 2006 10:42 AM
How to decompress Java applets bekim JSP Basics 0 January 23rd, 2005 05:56 AM
java coding for 3dbargraph applets,,help!!!! s.vidya Java GUI 0 October 15th, 2003 05:35 AM
3d java applets,,,help!! s.vidya Java GUI 0 October 15th, 2003 04:40 AM
Applets jwilliams2000 BOOK: Beginning Java 2 1 August 2nd, 2003 07:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.