We've developed a Java web application in Eclipse with a Swing GUI, all part of the same Eclipse web application project. We now want to be able to run the application outside an IDE, for example as a WAR or JAR file. We tried to deploy the application as a WAR using Tomcat and accessing it through the browser and the server is running but the GUI doesn't show up, naturally. Is there some way, preferably as simple and fast as possible, to be able to run the web application and at the same time have the GUI appear and be able to interact with it, the same way we did through Eclipse?
-
1maybe webswing as an option? I dont't think, that a desktop application can be simply run as a web applazyneuron– lazyneuron2017-10-16 13:57:14 +00:00Commented Oct 16, 2017 at 13:57
-
Probably you can use Java Web StartSergiy Medvynskyy– Sergiy Medvynskyy2017-10-16 14:01:23 +00:00Commented Oct 16, 2017 at 14:01
-
I'm not sure a Swing UI can run as a webapp but curious what you find out herejseashell– jseashell2017-10-16 14:05:34 +00:00Commented Oct 16, 2017 at 14:05
-
See : stackoverflow.com/questions/2261728/…c0der– c0der2017-10-16 14:21:57 +00:00Commented Oct 16, 2017 at 14:21
-
2Possible duplicate of Run a Java application in a web browserc0der– c0der2017-10-16 14:22:15 +00:00Commented Oct 16, 2017 at 14:22
|
Show 1 more comment
1 Answer
Thank you all for your help. I've solved the problem simply using embedded Tomcat (an example for using it can be found here(https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat). Instead of running Tomcat separately as a service, I ran it in embedded form within a Swing application to listen to HTTP GET/POST requests.
5 Comments
JavaUser
are you able to convert your swing GUI application as web based application? . Can you share the steps?
Yaniv Tzur
I'm not sure what you mean. If you mean to ask whether I have a systematic method to convert a Swing app to a web based application with a web front end, then no. This was an early server app I wrote (partially at least) where the actual server and a GUI for viewing and manipulating its data were part of the same executable. This is generally probably a bad idea, but this was achieved technically using a third party library that allowed running a tomcat service inside our executable. In this manner, our GUI code could interact directly with the code running the server.
JavaUser
Ok Yaniv. My requirement is , I have a swing desktop application.Is there way to access this desktop application by multiple users through browser?
Yaniv Tzur
What you need to do is isolate the internal logic of the swing application to a different application, a web service capable of handling HTTP requests. How you do that exactly can be achieved in several different ways but from what I know, in Java, the best way is to use the Spring framework. As for the frontend, I am a little less proficient in that, but it's a matter of how much time you can and need to devote. If it's a simple non-important app, you can just create a simple HTML page and have it make HTTP requests to your new service behind the scenes.
JavaUser
rewriting the complete app as web app is not recommended here. I need to convert some how like application virtualization.