PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 13, 2022

[FIXED] How to deploy Java Swing Application on Web Browser?

 July 13, 2022     applet, java, swing, web, web-deployment     No comments   

Issue

I've found exactly the same question I just made but it is 7 years old; so I'd like to have an "updated" answer if it is possible. Thanks.


Solution

Old days

As commented by TrogDor, there were previously two ways to deploy a Swing app through the web:

  • Java Applet technology
    Your app would appear within a rectangle on the web page, within the browser.
  • Java Web Start technology
    Clicking a link on a web page would download a copy of your Swing app to the user’s local machine, where your app would then be launched locally using a locally-installed JVM. So your app runs separate from the web browser. This click-to-download-and-run process is defined by Java Network Launching Protocol (JNLP).

Both of these are being phased out.

➥ For details, see the white paper Java Client Roadmap Update published by Oracle, updated 2020-05-11.

Nowadays

The modern approach is to build a Swing and/or JavaFX app, then deploy by using a packaging tool to include a JVM. You end up with a complete self-contained self-launchable application.

This means you need multiple builds, one app for each platform your users may deploy on (macOS, Linux, BSD, Windows, and so on). While that is an additional burden to you, the flip-side is that you control exactly what version of Java is being used to run your app.

Because of the Java Platform Module System (JSR 376) in Java 9 and later, you can now strip down the bundled JVM and libraries to include only the parts actually used by your particular app.

The build tools for packaging your app have been rapidly evolving in recent years. So be sure to do your research to find the most robust and modern tooling.

Alternatives

You might consider any of these alternatives:

  • OpenWebStart
    A re-implementation of Java Web Start
  • GraalVM
    Ahead-of-time native-code compilation of your Java app
  • Vaadin Flow
    Using Java to build desktop-style apps delivered as web apps

OpenWebStart

You might be interested in a separate implementation of Java Web Start technology.

While Oracle is phasing out Java Web Start, there is an open-source implementation of JSR 56: Java Network Launching Protocol and API called OpenWebStart. See GitHub. This project is currently maintained by the company Karakun, based on the IcedTea-Web core functionality developed at Adoptium (née AdoptOpenJDK).

GraalVM

A cutting-edge alternative is to build an entirely native-code ahead-of-time compiled version of your app using GraalVM.

Vaadin Flow

An entirely different way to build a web app by using Java is the Vaadin Flow framework.

You specify your user-interface layouts with widgets in a manner quite similar to Swing, specifying an arrangement of widgets (buttons, fields, labels, etc.). You can do so using your choice of straight Java code, an XML-based description language, or a visual design tool.

At run-time, Vaadin automatically automatically generates the HTML, CSS, and JavaScript necessary to render your app remotely on the client user’s machine within a web browser. So, you have pure Java on the server-side, and no Java on the client-side, just Web standards technologies built into all modern browsers.

More info

All of this has been covered many times already on Stack Overflow. So search to learn more.

For tips on obtaining a JVM to bundle with your app, see How to get java 11 run-time environment working since there is no more jre 11 for download?.



Answered By - Basil Bourque
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing