简体   繁体   中英

java applet not working in html

I have a very simple problem. My "Hello World" applet is not transferring into html for some reason.

I am providing the code class and code base to upload the file, but for some reason, the html states that there is an error and the error looks like a bunch of commands from an operating system terminal.

I am using Mac OS and the coding for the Java and HTML are the following:

import java.awt.*;

public class Hello extends javax.swing.JApplet {
    String greeting;

    public void init() {
        FlowLayout flo = new FlowLayout();
        setLayout(flo);
        greeting = "Hello!";
    }

    public void paint(Graphics screen) {
        Graphics2D screen2D = (Graphics2D) screen;
        screen2D.drawString(greeting, 25, 50);
    }
}

I have the HTML set up properly with the tags, head, title, and body. The applet is in the body and is coded as the following:

applet width="400" height="200" codebase="..\\..\\build\\classes" code="Hello.class" 

Any help is much appreciated.

Create an html file in the directory where Hello.class is, containing this:

<applet width="400" height="200" codebase="." code="Hello.class">

Open it with your browser, and if your Java plugin is configured correctly you should see the applet. It works for me:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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