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);
}
}
这是终端的输出
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)
我该怎么办??我似乎无法弄清楚我的代码或我安装的 jdk 有什么问题。请帮我解决这个问题。我什至尝试通过从 .java 文件中删除小程序代码并创建一个 html 文件来单独使用 html,如下所示。我所有的浏览器都无法加载插件。是浏览器的问题还是小程序的问题?html代码:
<html>
<head>
<title>ABCD</title>
<applet code = App width=200 height=200>
</applet>
</html>