user994165
user994165

Reputation: 9502

Converting Java Desktop Application to Web using Applet or Java Web Start

I know that I can convert a Swing application to an Applet or a Java Web Start application. Is it possible to do the same with an application that's not Swing, say Qt using Java?

What I'm really looking for is a UI framework using Java that's as cross-platform as possible and also has a rich set of UI functionality. Being able to run the application as either a desktop or a Web application would be preferable.

Upvotes: 1

Views: 1808

Answers (4)

user1657170
user1657170

Reputation: 318

If you want to use Qt you would first have to make Qt bindings for Java as they are not currently functional.

If you want to use Qt bindings from a Java Applet you will need to make your bindings an installable extension which would be a potential security risk unless you know what you are doing. You would also have to get the user to install your extension. Also IcedTea-web which are the FOSS plugin shipping with Linux will not load an extension. So if you want your extension to work on Linux you will have to fork IcedTea-web and make your own plugin.

So the short answer: Stick to Swing.

Upvotes: 0

jewelsea
jewelsea

Reputation: 159281

What I'm really looking for is a UI framework using Java that's as cross-platform as possible and also has a rich set of UI functionality.

Assuming a desktop deployment, the three major frameworks are Swing, SWT and JavaFX.

Try the JavaFX Ensemble sample to see if that technology would suit your needs.

I know that I can convert a Swing application to an Applet or a Java Web Start application. Is it possible to do the same with an application that's not Swing, say Qt using Java?

QT is native code that doesn't run on the JVM - it is not a Java UI framework. Applet and Web Start programs require a Java class as their entry point. Any use of QT is such a scenario would require a Java <=> QT adaption layer and I am not aware of the existence of any such thing - you would probably need to build it yourself based on a technology like JNI.

Being able to run the application as either a desktop or a Web application would be preferable.

See the JavaFX deployment guide for various JavaFX deployment options and the Swing deployment guide for various Swing deployment options.

The definition of Web application is pretty nebulous. Here are some distinct scenarios:

  • You are restricted to just html5 => produce the html on a server to distribute to the client.
  • You want html launching a Java application => then something like WebStart in combination with the Java Deployment Toolkit can be used.
  • You will be rendering a JavaFX application inside a browser window => then use a browser embedded app.

There are many pitfalls for embedding java applications is web pages (just use google to discover some of them).

Upvotes: 2

finnw
finnw

Reputation: 48619

Java Web Start apps can contain native libraries, so yes you should be able to convert an app using Qt (assuming the bindings exist) to a JWS app.

Applets on the other hand are tricky to make work with anything other than AWT/Swing, since you have no control over the creation of the top-level window.

Upvotes: 0

Alfredo Osorio
Alfredo Osorio

Reputation: 11475

What I have done in one of my projects is develop the application as a web application and then generate a installable to distribute my application. This has great benefits:

  1. It can be installed in a server and publicly available. Just as a normal web application.
  2. It can also be installed in a desktop.

I used "Jetty" to embed the web server in my application and be able to run the application as a stand alone in desktop environment. The slogan of Jetty is "Don't deploy your application in Jetty, deploy Jetty in your application."

Also I used "IzPak" to package my application in a executable JAR for installation. If you want to make that JAR easy to install for people who might not have installed Java you can use launch4j which is a tool that wraps the JAR into an EXE. So it can validate first if the computer has already Java and if not inform the user that he needs to have Java installed to proceed. The only drawback of this is that if you wrap your application in an EXE you are limiting the portability to other platforms, but that's your decision according to the requirements.

Upvotes: 0

Related Questions