简体   繁体   English

无法执行小程序(小程序未初始化)

[英]Unable to execute applet program(applet is not initialized)

import java.awt.*;
import java.applet.*;

/* <applet code="Demonstration_21" width=300 height=300> </applet> */
public class Demonstration_21 extends Applet{

    public void paint(Graphics g){
    g.drawString("Welcome",150,150);
    }
}

I have written this code to run an applet program but whenever I compile it gives some warning as: 我已经编写了这段代码来运行applet程序,但是每当我编译它时,都会发出如下警告:

  1. Demonstration_21.java uses or overrides a deprecated API Demonstration_21.java使用或覆盖已弃用的API
  2. Recompile with Xlint:deprecation for details. 使用Xlint:deprecation重新编译以获取详细信息。

And whenever I run this code it gives error as: 每当我运行此代码时,它都会给出如下错误:

Demonstration_21 has been compiled by a more recent version of Java
Runtime(class file version 55.0),this version of Java Runtime only 
recognizes class file versions up to 52.0

My appletviewer is not initialized. 我的appletviewer未初始化。

You should build it with Java 8 instead of Java 11. 您应该使用Java 8而不是Java 11来构建它。

Here is a list of class file versions an the related Java major versions List of Java class file format major version numbers? 这是类文件版本和相关Java主要版本的列表Java类文件格式主要版本号的列表?

you miss something.. 你错过了一些..

In applet tag code attribute you have to specify .class file. 在applet标签代码属性中,您必须指定.class文件。

import java.awt.*;
import java.applet.*;

/* <applet code="Demonstration_21.class" width=300 height=300> </applet> */
public class Demonstration_21 extends Applet{

    public void paint(Graphics g){
    g.drawString("Welcome",150,150);
    }
}

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

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