The moose likes Applets and the fly likes applet not running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "applet not running" Watch "applet not running" New topic

applet not running

Roda Aing

Joined: Jul 13, 2004
Posts: 7
Hi there,

I am having problem with my java applet code. I have the following file.

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

class getValue
int count=0;
int[] y = new int[1560];

public void getx() throws IOException
FileInputStream LogFile = new FileInputStrea ("Record.log");
DataInputStream in = new DataInputStream(LogFile);
while (in.available() !=0)
y[count] = Integer.parseInt(in.readLine());

public class FirstLine extends Applet
public void paint(Graphics g)
getValue x;
x = new getValue();
catch (IOException e)
g.drawString("File not found", 100, 100);
g.drawString("Mobitel", 100, 100);
for (int i=0; i < 383; i++)
g.drawLine(i, 300-x.y[i], i, 300-x.y[i+1]);

And below is my html code of the file named FirstLine.html

<applet code=FirstLine.class width=400 height=300>

The problem is that I can sucessfully run the applet in appletviewer, but failed to run in web browser. I am using Internet Explorer.

Can anyone help me to correct my code?

Joe Ess

Joined: Oct 29, 2001
Posts: 9150

How about opening the java console and seeing what the error is? I will bet it is a security exception. Unsigned applets can't open files on the client computer.

[How To Ask Questions On JavaRanch]
Yagyesh Gaur

Joined: Jul 20, 2004
Posts: 2
Try using the below html lines and check out that class file and html files are in the same directory.

<applet code="FirstLine.class" width=400 height=300></applet>
I agree. Here's the link:
subject: applet not running
It's not a secret anymore!