Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding two integer values by passing parameters through an applet
    primarykey
    data
    text
    <p>The following java program gets compiled successfully but when I try to run it using <strong>appletviewer</strong>, I get the following (in command prompt) with a message "<strong>applet not initialized</strong>" in the applet window.</p> <pre><code>import java.applet.*; import java.awt.*; /* &lt;applet code="ParamDemo" width="300" height="300"&gt; &lt;param name="first" value="20"&gt; &lt;param name="second" value="30"&gt; &lt;/applet&gt; */ class ParamDemo extends Applet { int x,y,sum; public void init() { x=Integer.parseInt(getParameter("first")); y=Integer.parseInt(getParameter("second")); } public void paint(Graphics g) { sum=x+y; g.drawString("Total Sum is"+sum,100,100); } } </code></pre> <p>in the Command prompt -</p> <pre><code>C:\Documents and Settings\Salman\Desktop&gt;javac ParamDemo.java C:\Documents and Settings\Salman\Desktop&gt;appletviewer ParamDemo.java load: ParamDemo is not public or has no public constructor. java.lang.IllegalAccessException: Class sun.applet.AppletPanel can not access a member of class ParamDemo with modifiers "" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95) at java.lang.Class.newInstance0(Class.java:368) at java.lang.Class.newInstance(Class.java:327) at sun.applet.AppletPanel.createApplet(AppletPanel.java:793) at sun.applet.AppletPanel.runLoader(AppletPanel.java:722) at sun.applet.AppletPanel.run(AppletPanel.java:379) at java.lang.Thread.run(Thread.java:722) </code></pre> <p>I am unable to figure out the problem ...</p> <p>Any help would be appreciated !</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload