Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Hello world applet cant load in browser but able to load in appletviewer

Posted on 2003-02-20
9
Medium Priority
?
284 Views
Last Modified: 2013-11-23
i try to load my helloworld but it cant load in IE but it manage to load in appletviewer. i have alreadi read thru some of the simalar question but it doesnt help cox it say swing plugin but for tis simple hello world ther not even a swing plug in. thanks if any of you can help me check thru the code

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

public class graph extends Applet {
   public void paint(Graphics g) {
      Font font = new Font ("SansSerif", Font.BOLD, 26);
      g.setFont(font);
      g.drawString("Hello world!", 50, 25);
   }
}
--------------HTMl FILE----------------
<HTML>
<HEAD>
<TITLE> Hello World </TITLE>
</HEAD>
<BODY>
<font size = +5>
Here is Hello World1 applet:<br>
<APPLET CODE="graph.class" WIDTH=500 HEIGHT=25>
</APPLET>
</font>
<br>
<p>
</BODY>
</HTML>
------------------------------------
all of them reside in the same folder say C:\test  
0
Comment
Question by:crappy35
9 Comments
 

Expert Comment

by:suryakumar
ID: 7986081
Add the comment shown and recompile the class and then open the HTML file in a browser

/*<applet code="graph.class" width=500 height=25></applet> */
import java.applet.Applet;
import java.awt.*;

public class graph extends Applet {
  public void paint(Graphics g) {
     Font font = new Font ("SansSerif", Font.BOLD, 26);
     g.setFont(font);
     g.drawString("Hello world!", 50, 25);
  }
}

0
 
LVL 3

Expert Comment

by:schybert
ID: 7986084
What error message do you get?
0
 

Author Comment

by:crappy35
ID: 7986178
it says load: class graph not found
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:davestubbs
ID: 7986755
The class file MUST be in the same directory on the server as the page from which you loaded it.

You also do not need to specify the .class, so just use

<APPLET CODE="graph" WIDTH=500 HEIGHT=25>
0
 

Author Comment

by:crappy35
ID: 7987844
ok there noting wrong with the coding becos i manage to test it on my laptop and it works but it doesnt work on the desktop ...what could possibly be the reason?
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 7988192
Are you creating a jar with your class file? If so, you need to specify the 'archive' parameter.
0
 

Author Comment

by:crappy35
ID: 7990973
nope no jar..
0
 

Accepted Solution

by:
drumkit17 earned 150 total points
ID: 7991307
try installing reinstalling run time enviroment for jdk
0
 

Author Comment

by:crappy35
ID: 7991319
ya i manage to slove the problem, is either i reinstall jdk runtime new version or i recompile the applet in jdk1.2 version. and it works
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question