1
import java.awt.*;
import java.io.*;
import java.applet.*;
/*<applet code = App width=400,height =400>
</applet> */
class App extends Applet
{
    String str = " ";
    public void init()
    {
        str= "from int method";
        System.out.println(str);
        repaint();
    }

    public void start()
    {
        str= "from start method";
        System.out.println(str);
        repaint();
    }

    public void stop()
    {
        str= "from stop method";
        System.out.println(str);
        repaint();
    }

    public void destroy()
    {
        str= "from destroy method";
        System.out.println(str);
        repaint();
    }
    public void paint (Graphics g)
    {
        g.drawString(str, 200, 200);
    }
} 

This is the output of the terminal

    sumedh@sumedh-h9-1325in:~$ appletviewer App.java
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/local/java/jdk1.8.0_05/jre/lib/i386/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1083)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1835)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1119)
    at java.awt.Toolkit$3.run(Toolkit.java:1651)
    at java.awt.Toolkit$3.run(Toolkit.java:1649)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Toolkit.loadLibraries(Toolkit.java:1648)
    at java.awt.Toolkit.<clinit>(Toolkit.java:1683)
    at java.awt.Component.<clinit>(Component.java:595)
    at sun.applet.Main.run(Main.java:156)
    at sun.applet.Main.main(Main.java:98)

What do i do?? I can't seem to work out what is wrong with my code or with the jdk i installed. Please help me figure this out. i Even tried using html separately by removing the applet code from the .java file and creating an html file as below. All my browsers fail to load the plugin. Is that a browser problem or something with the appplet again? HtML Code:

<html>    
<head>
<title>ABCD</title>
<applet code  = App width=200 height=200>
</applet>
</html>
mpromonet
  • 11,326
  • 43
  • 62
  • 91

1 Answers1

1

Your entire code seems to be fine. The problem here is in the tag. Put the name of your .java file in double quotes i.e use as follows

       code = "App" width=400,height =400
Parth
  • 568
  • 2
  • 6
  • 23