ERROR IN RUNNING A JAVA APPLET

Questions about programming languages and debugging
Post Reply
User avatar
intern3t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 119
Joined: 18 Aug 2010, 02:06
13

ERROR IN RUNNING A JAVA APPLET

Post by intern3t »

I was trying to run an applet with firefox browser.here is error i got.

Code: Select all

Java Plug-in 1.6.0_20
Using JRE version 1.6.0_20-b02 Java HotSpot(TM) Client VM
User home directory = C:\Users\BLUE-WINGS
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------


load: class DrawStringApplet.class not found.
java.lang.ClassNotFoundException: DrawStringApplet.class
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Users\BLUE-WINGS\Desktop\classes\DrawStringApplet\class.class (The system cannot find the path specified)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 7 more
Exception: java.lang.ClassNotFoundException: DrawStringApplet.class
Please how do i fix this?Thanks

User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

Re: ERROR IN RUNNING A JAVA APPLET

Post by l0ngb1t »

source code ?
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

User avatar
intern3t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 119
Joined: 18 Aug 2010, 02:06
13

Re: ERROR IN RUNNING A JAVA APPLET

Post by intern3t »

l0ngb1t wrote:source code ?

Code: Select all

import java.applet.Applet;    
import java.awt.Graphics; 
             
public class DrawStringApplet extends Applet {

  String input_from_page;

  public void init() {
    input_from_page = getParameter("String");
  }
  
  public void paint(Graphics g) {
    g.drawString(input_from_page, 50, 25);
  }
  
}

User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

Re: ERROR IN RUNNING A JAVA APPLET

Post by l0ngb1t »

your code is correct however make sure that you name your file DrawStringApplet.java
compile using the command: javac DrawStringApplet.java
now DrawStringApplet.class will be created after its compiled
place it in the same directory as test html file and it open the html file.

I've used the following html code to test it

Code: Select all

<Html>
<Head>
</Head>
<Body>
<Applet Code="DrawStringApplet.class" width=200 Height=100>
<Param Name=String Value="some value"> 
</Applet>
</Body>
</Html> 
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

Post Reply