简体   繁体   中英

Show Java Application as Webdemo in Browser

I have a finished, working java project using swing and awt. It works as executable jar, but I want to upload it on a webserver to be a working live demo. This is the main class, there are many other classes used. I found out about java.applet.Applet, but how can I implement it the best way?

import javax.swing.*;
import java.awt.*;

public class TicTacToe extends JFrame implements Components
{
    

    public TicTacToe()
    {
        super("TicTacToe V1");
        add(statusbar, BorderLayout.NORTH);
        add(playground, BorderLayout.CENTER);

        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(800,600);
        setResizable(false);
        setVisible(true);

    }

    public static void main(String[] args){
        TicTacToe tictactoe = new TicTacToe();

    }

}

You might consider using CheerpJ: https://github.com/leaningtech/cheerpj-meta

CheerpJ allows to run unmodified Java applications (and even legacy applets) in the browser without any binary plugins. It is free for non-commercial applications.

Full disclosure: I am lead developer of CheerpJ, and CTO of the company that maintains the project.

Applets don't work anymore. There is no standard technology in modern versions of Java that allows you to do this so it works in all browsers.

Best bet is to create a zip file that users can download, unpack and run.

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