简体   繁体   English

Applet查看器运行时错误。 Appletviewer无法打开

[英]Applet viewer Run-time error. Appletviewer not opening

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. 我似乎无法弄清楚我的代码或安装的jdk出了什么问题。 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. 我什至尝试通过从.java文件中删除applet代码并按如下方式创建html文件来单独使用html。 All my browsers fail to load the plugin. 我所有的浏览器均无法加载该插件。 Is that a browser problem or something with the appplet again? 是浏览器问题还是再次出现问题? HtML Code: HtML代码:

<html>    
<head>
<title>ABCD</title>
<applet code  = App width=200 height=200>
</applet>
</html>

Your entire code seems to be fine. 您的整个代码似乎很好。 The problem here is in the tag. 问题出在标签中。 Put the name of your .java file in double quotes ie use as follows 将您的.java文件名放在双引号中,即按如下方式使用

       code = "App" width=400,height =400

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM