Search code examples
javawebexecutable-jarjapplet

How to: JAR -> Web hosted application?


I've been looking around so please excuse me if I missed it, I know there are a lot of threads that deal with this sort of thing, but I haven't found a clear answer yet.

My question is (I think) quite simple. I have an executable JAR file (created in Eclipse) and I want to host it on my website, presumably as an Applet. I have little understanding of applets, just that they are Java executables that run on webpages.

Is this transition trivial, or does will it require me to pretty rewrite my program entirely? Baring in mind it relies heavily on Swing components such as JTabbedPanes, JButtons, JLabels, etc.

Thanks!

EDIT: Thanks to an answer, I've rewritten my components to be applet friendly inside of a class which extends Applet and build my GUI as you did within the run() method. My problem now is that before, I had a run method for the program itself (it's a simulation of sorts). Within, it simply updated certain things over time, but did so in an infinite loop. Without this run code, my applet can build the GUI, but the GUI stands no purpose without the run code, which causes the applet to fail to load any components. Any thoughts?

EDIT_2: I've just decided to use Java Web Start. Thanks.


Solution

  • You don't need to convert it into an applet. You can just use Java Web Start.