giri
giri

Reputation: 27199

how to make my desktop application to web app application in java

I have designed a GUI connect to DB button using Swing in java now i want to make it webapp application I need to host it on my website. Do i need to replace all my coding as swing is only for desktop application. Or is there any other way?

Upvotes: 0

Views: 2684

Answers (8)

user1367814
user1367814

Reputation: 21

Take a look at AjaxSwing. It is a web deployment platform for Java Swing applications. It allows companies that built Java desktop applications to run them as web applications. Because it produces pure HTML/JavaScript you can also run Swing application on iPhone, iPad and Android phones.

Upvotes: 1

deamon
deamon

Reputation: 92437

What can be reused depends upon your architecture. Look at Wicket, which offers a programming model very similar to Swing. That would not avoid rewriting of the GUI but makes the "mental mapping" easy.

Upvotes: 0

Bozho
Bozho

Reputation: 597096

If I'm getting it correctly, you need to reuse a database connection code. In that case:

You need to remove only the code that references Swing components. The ones that start with J. More accurately - the ones that are in package javax.swing or java.awt. The rest of the code can stay.

However, if your database connectivity code is too coupled to the GUI code, you'd better start that from scratch and just copy-paste of the parts in your Swings application.

In case you have a big Swing application, then you might want to use an automatic converter to web (ajax) application instead.

One such solution is AjaxSwing. There may exist others as well.

Upvotes: 1

Salvin Francis
Salvin Francis

Reputation: 4267

Check GWT, its a great framework that allows you to code in java...

Upvotes: 1

Sylar
Sylar

Reputation: 2333

You can turn your swing application into an applet, then it will run in a web browser, provided a JRE is installed on the client machine.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500515

It will partly depend on how well you've structured your application. If there's no layering involved - if the GUI classes connect directly to the database, for example, then yes, you'll need to rewrite the whole thing.

If, however, you already have a separate data access layer, business logic layer and presentation layer, then you may only need to completely rewrite the presentation layer - while checking the other layers for things like concurrency safety.

The stateless nature of web applications - aside from session-based state - may mean you need to redesign the application significantly, of course. This may in turn mean that your existing "backend" layers aren't quite appropriate. While the theory is that they'd be presentation-layer-neutral, in my experience it would be quite unusual to manage to write an app targeting a single UI technology without some of the usage assumptions leaking through into underlying layers.

Upvotes: 4

Jakub Arnold
Jakub Arnold

Reputation: 87210

If you want a Swing like application on the web, you can use an Applet.

Upvotes: 0

laura
laura

Reputation: 7332

Yes you need to replace all the GUI layer with web-app stuff (jsps, controllers etc). It should be relatively easy if you kept the business layer separated from the GUI layer. I suggest taking a look at Spring Framework, it is very useful for developing web apps.

Upvotes: 0

Related Questions