• 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

Prevent application from closing when user logs off

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

I made a multithread application that has a GUI (swing) , uses sockets to communicate to other instances of it in VPN , comminicates with DB and does many other things...

My problem is that when user logs off, this application turns off also, and need to make it not to close when user logs off.

Now, I know that -Xrs JVM option prevenets from closing it, and I tried using it and it doesn't help!

I tried opening my app with

java -jar -Xrs file_name.jar

but when I log off, this application terminates as well...

Am I missing something?
Can you help me with this?

Thanks.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Logs off of what? The OS? If it is, then you'll need to start your Java process in a way that the OS knows to keep it running, e.g. by running it as a Windows service or in nohup mode on *NIX systems.
 
Michael Brown
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, log off in windows...

Hmmm... isn't this a problem with JVM ?
Is it not that JVM is to blame , because when user logs off JVM terminates as well?

Than I should prevent JVM from terminating, not just my application?

If it is, then you'll need to start your Java process in a way that the OS knows to keep it running, e.g. by running it as a Windows service.



Do you know any other way ? Or, how to do this? (Is it even possible to run GUI application as service?)
[ November 25, 2008: Message edited by: Benny Lava ]
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hmmm... isn't this a problem with JVM ?


No. All processes started by a user in Windows will be ended when they log off.


Do you know any other way ? Or, how to do this? (Is it even possible to run GUI application as service?)


There are Java service wrappers out there (have a google). Normally running a GUI app. from a service is a no-no, so you may need to re-write the bit you don;t want to end. That being said, I've never tried it with a Java GUI application.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Benny Lava:
Do you know any other way ? Or, how to do this? (Is it even possible to run GUI application as service?)



You can wrap your application in a services wrapper. Search for Java Windows Service Wrapper for ways to do this.
Your service won't be able to have a GUI because there will be no desktop for the GUI to be displayed on, but if you're logged off why do you need a GUI ?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know where you got the idea that -Xrs keeps the JVM from exiting. Actually, what it does is ensure that when the JVM gets many OS signals, it dies immediately, instead of handling the signals gracefully.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends on exactly what you are doing in the GUI, but you could put all the VPN/DB code into a application that runs as a service and then have a separate front end GUI that starts up and connects to the service whenever you log in.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Services can be setup to be able to interact with the desktop, which is something you will need if you want the GUI to be a real part of the service and not some controller like Joanne has suggested.

I've seen a few services that have a tray icon for controlling. Apache Tomcat is one of them
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Benny,

Please read your private messages regarding an important announcement.

Thank you,

Rob
 
Michael Brown
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for your answers.

I'll try some of the solutions you provided...
[ November 26, 2008: Message edited by: Michael Brown ]
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic