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();
}
}
CodePudding user response:
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.
CodePudding user response:
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.