• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling a GUI application from Servlet

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to call a GUI application(not an applet) from a servlet. Can somebody exlain me how it can be done?
Thanks in advance.
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean a GUI on the server side or on the client side?
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have never tried it. But you can definitly try

Runtime rt = System.getRuntime();
rt.exec("java MainClass"); // MainClass which loads the GUI


Regards
Atul
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the question here is "why" do you need to call a GUI application from a servlet? Does it write out some file that you need to relay to the client or something?
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try to launch a GUI on the server but this will most likely fail.
Many servers don't have videohardware installed in which case Swing and AWT will throw a fit.
Even if there is videohardware installed, there is most likely noone to interact with the GUI.
And what will you do if there's multiple requests coming in, each of which tries to launch that GUI?
It could quickly become a mess for the poor soul you've drafted to use all those started applications.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I need to call a GUI application(not an applet) from a servlet. Can somebody exlain me how it can be done?
Thanks in advance.



Can you take a little more time to explain what it is that you want to do?
There are several different ways to get Java apps to talk to one another. The best one depends on your requirements.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen Wenting:
You could try to launch a GUI on the server but this will most likely fail.
Many servers don't have videohardware installed in which case Swing and AWT will throw a fit.
Even if there is videohardware installed, there is most likely noone to interact with the GUI.
And what will you do if there's multiple requests coming in, each of which tries to launch that GUI?
It could quickly become a mess for the poor soul you've drafted to use all those started applications.



Swing applications can be run "headless" now, so you don't need something like Xvfb (X Virtual Frame Buffer) to "mock" a graphics environment. That isn't to say that running a graphical application during a request is a good idea.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maybe they can in some circumstances, but can they be run headless when there's a screen that a user needs to type something into?

Kinda hard to have a headless application if that application is waiting for input that never arrives because there's no screen to enter it into (or there is a screen but no person to look at it).
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point! :-) But, I only brought up the headless option because I have written webapps that needed to use the AWT/Swing classes to "paint" and the imageio package classes to return the dynamically generated images. Maybe that's what they're doing and that's what they meant by "gui application"? Who knows. I would hope that they aren't actually trying to popup a screen for someone to input something as part of the request. There are better ways to do something like that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic