Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 22nd, 2003, 12:32 PM
Authorized User
 
Join Date: Jun 2003
Location: Jewett City, CT, USA.
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
Reply With Quote
  #2 (permalink)  
Old August 23rd, 2003, 01:31 AM
Authorized User
 
Join Date: May 2003
Location: New Delhi, Delhi, India.
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
Reply With Quote
  #3 (permalink)  
Old August 23rd, 2003, 09:56 AM
Authorized User
 
Join Date: Jun 2003
Location: Jewett City, CT, USA.
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.
Reply With Quote
  #4 (permalink)  
Old August 26th, 2003, 06:51 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
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

Reply With Quote
  #5 (permalink)  
Old August 27th, 2003, 12:54 AM
Authorized User
 
Join Date: May 2003
Location: New Delhi, Delhi, India.
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
Reply With Quote
  #6 (permalink)  
Old August 27th, 2003, 12:32 PM
Authorized User
 
Join Date: Jun 2003
Location: Jewett City, CT, USA.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
No more Java Applets for me... larry Javascript 0 January 10th, 2006 09:42 AM
How to decompress Java applets bekim JSP Basics 0 January 23rd, 2005 04: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



All times are GMT -4. The time now is 02:31 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.