1

I'm going to migrate a Java Applet to be started via JNLP as a Java Web Start Application and run into some troubles/missunderstandings ...
One of the resources I've got is this: 6 Migrating Java Applets to Java Web Start and JNLP:

But let's start:

Currently the application is an applet (JApplet) and was started in past by embedding into an HTML with the applet tag referring to a JNLP.

Now since applet support was dropped by all browsers, I should run it as Java Web Start.

Simply calling same JNLP failed as the resources (JAR files) couldn't be loaded.
This was as a first step fixed by adding an code base attribute to the JNLP file.

Applet is starting outside of the browser.

But now the hard part ... I should/would like to get rid of any applet dependency.

But how?
What is the right approach for that?
The guide doesn't really tell, and therefore I have some questions:

  1. e.g.: How do I replace the usage of the applet.getAppletContext() and related usage of it?
  2. The guide says I should place a static main in my "main" applet class. But How should I do this?

I tried & to start the applet in different ways, but after that my applet was not starting any more.

How do I really replace it?
What should be the right wrapper for an application instead of applet?
How to start it?

Is there maybe a more elaborate guide/sample/tutorial to follow with a real example?

4
  • Is it really a good idea to use Java Web Start in 2017 / 18 ? It cannot be run in mobile environment at all. Commented Dec 15, 2017 at 1:42
  • 1
    What methods of AppletContext are of interest to you? You can load images with the javax.imageio package; you can play sounds with the javax.sound.sampled package. Commented Dec 15, 2017 at 2:08
  • Either question 1 or question 2 makes for a separate question thread that is almost 'too broad' each on their own. Voting to close as too broad. Please split your questions into (at least) two threads, and even then, do some work and ask much more specific questions. For example for the 1st part, as suggested by @VGR, specify which of the ten methods of the applet context, the applet currently uses. Commented Dec 15, 2017 at 2:36
  • ""How to start it? For the 2nd part. Recode the GUI in a JPanel that can be placed in either a JApplet or a JFrame. Search the posts of trashgod or myself for 'hybrid'. Those answers discuss (& often show) how to make an app. that can work as either an applet or an application. If you want to go a step further and remove applet support completely, it should be easy once there is a working hybrid applet/application. Commented Dec 15, 2017 at 2:51

1 Answer 1

2

An alternative containment for you application could be a JFrame.
A migration path would be refactoring (moving) the actuall UI Code into a JPanel. That one can be placed into the JApplet or for an Java WebStart application into a JFrame. (during that time you could have a hybrid application).

<!-- main in MyApplication --> public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); frame.setTitle("MyApplication via JWS"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // add here the real UI to the frame: setUpGUI(frame); frame.pack(); frame.setVisible(true); } }); } <!-- Init() in MyApplication extends JApplet --> @Override public void init() { EventQueue.invokeLater(new Runnable() { public void run() { // add here the real UI to the applet: setUpGUI(MyApplication.this); } }); } 

Note: the EventQueue.

According Question 1:
Some of the Applet specifica have to be replaced be different ways.
Find the basics here: https://docs.oracle.com/javase/9/deploy/jnlp-api-examples.htm
e.g.: for AppletContext there is the BasicService as some kind of replacement.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.