• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

applet not running

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

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


import java.io.*;
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());
count++;
}
}
};

public class FirstLine extends Applet
{
public void paint(Graphics g)
{
getValue x;
x = new getValue();
try
{
x.getx();
}
catch (IOException e)
{
g.drawString("File not found", 100, 100);
}
this.setBackground(Color.white);
g.drawString("Mobitel", 100, 100);
this.setForeground(Color.blue);
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>
</applet>

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?

Thanks
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
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>
Bye
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic