• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running applets

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone pls, give me the steps (procedure) to run a applet.
Thanks.....
 
Jesper Ottosson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make a class that extends Applet, compile it, put a html-document in the same dir as the just created .classfile. In the html, type:
<applet code="MyClass.class" width="100" height="100"></applet>

that should do it.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you are using a java ide, just follow the tutorial. if u are using a jdk, type a html file and a java file and compile and run. then use a java enabled web browser to view the applet.
 
paul wheaton
Trailboss
Pie
Posts: 21890
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Priya,
Is this enough info? Is there a particular part you are getting stuck on?
If you're looking for a book, I suggest Just Java by Peter van der Linden. See www.javaranch.com/books.html
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.... I shall try that.....
Originally posted by Jesper Ottosson:
make a class that extends Applet, compile it, put a html-document in the same dir as the just created .classfile. In the html, type:
<applet code="MyClass.class" width="100" height="100"></applet>

that should do it.

 
David Woods
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, sounds simple enough. Here is my java source code:

import java.awt.*;
import java.applet.*;
public class myclass extends Applet {
public void paint(Graphics g) {
g.drawString("hello world",20,20);
}
}

I compiled it up and put it in an <applet> tag like this:

<applet code="myclass.class" height=200 width=400>
</applet>

But when I view the HTM file in the IE browser, all I get is a blank grey rectangle. Shouldn't I get, like, a message saying "hello world" or something? What am I doing wrong?
 
Murali Kurukunda
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you have for both the html and java is working fine on my machine.
Are you seeing any error messages in the java console? I have JRE 1.4.2_05 on my machine.
 
David Woods
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No messages, no nothing, just a grey rectangle in the IE browser.

My JRE version is 1.4.2_06, and my IE version is 6.0.2800.

p.s. I also tried the <object> tag. no work either.

help!!
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In IE, if you use the Tools menu to select Internet Options, then click on the Advanced tab, then scroll down to "Java (Sun)," I'm guessing you'll see that IE is trying to use a different JRE than what you have.

I just ran into this when I upgraded Java to 1.5.0, which stopped applets from working in IE 6.0.x. I didn't see any way to update this in IE -- the only options were enable or disable.

But when I tried to open the same page using Netscape 7.0, Netscape was kind enough to recognize the problem and re-direct me to...

http://www.java.com/en/download/manual.jsp

I'm not up on how browser plug-ins work, but I'm guessing this (j2re1.4.2_05) is the most recent version for IE. (Does that make sense?)

Anyway, it fixed the problem for me. Although if there's a way to get IE to use jre1.5.0, I would appreciate hearing about it...
[ October 29, 2004: Message edited by: marc weber ]
 
Murali Kurukunda
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is how you set JRE in IE. Setting-->ControlPanel-->Java Plug In-->open Browser-->tick the IE checkbox.
 
David Woods
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks to all of you who have responded to this thread with tips and pointers.

I have gone to InternetOptions->Advanced and clicked on the check box for "Use Java 2 Sun for <applet" and I have gone to the control panel to run the "Java Plug-in" configuration tool and tried all sorts of variations and versions, and I even re-downloaded and re-installed the JRE from the website and rebooted and I even tried running it under a desktop version of IIS and basically I have spent about a month trying to write a Java Applet that displays "hello world" and all I get is a grey rectangle.

There has just got to be something incredibly stupid I am doing wrong here, but for the life of me I can't figure out what it is. A steak dinner is promised for anyone out there who can point me in the right direction.

My code is about 2 posts back.

p.s. It works in the AppletViewer but not in the Internet Explorer.

David
 
Peter Chinaka
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have u tried checking the location of your class file again. The problem could simply be solved by pointing the browser to the right direction . Maybe you could try
<applet = "c:yourclassdirectory/../Hello Wolrd.class ...
</applet>
[ November 19, 2004: Message edited by: Peter Chinaka ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic