LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-16-2006, 03:49 PM   #1
MRMadhav
Member
 
Registered: Nov 2005
Location: Mauritius
Distribution: PCQLinux, SUSE Linux,Fedora Core 5, Fedora Core 6, Knoppix Live, Kubuntu Edgy, PCLinuxOS
Posts: 167

Rep: Reputation: 30
Question Launch command before java app exits


Hi,
Am trying to control the users in my Java application. For that i need to know how to launch a few commands when the user clicks the exit button or presses the X on the upper Right corner of the app. And If there could be some help on how to know if the program terminated unexppectedly the last time the user was logged on it would be very helpful!
 
Old 05-16-2006, 04:12 PM   #2
Mega Man X
Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 63
If you want to track when a Window is closed, you will need to add a listener to your window, just like you do with any other Component (as a button, for example). Take a look in this link:

http://www.dedserius.com/~vanboers/O...wlistener.html
 
Old 05-17-2006, 01:41 AM   #3
MRMadhav
Member
 
Registered: Nov 2005
Location: Mauritius
Distribution: PCQLinux, SUSE Linux,Fedora Core 5, Fedora Core 6, Knoppix Live, Kubuntu Edgy, PCLinuxOS
Posts: 167

Original Poster
Rep: Reputation: 30
Thanks that was very helpful but there is nothing on how to know if the app terminated unexpectedly or was killed
 
Old 05-17-2006, 08:35 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Use something like a log file. Write something like 'yyyy-mm-dd hh:mm:ss program started, pid=....' to it when the app starts.
Write something like 'yyyy-mm-dd hh:mm:ss program terminated normally, pid=....' just before the program terminates normally.
If the latter does not show up in the logfile, you know it did not terminate normally.

Or write a pid to a file when the app starts and remove this file when the app terminates normally (often used to check if an app is already running) On startup, check the file. If the pid-file is there at next startup, there was an unexpected termination.
 
Old 05-17-2006, 12:25 PM   #5
MRMadhav
Member
 
Registered: Nov 2005
Location: Mauritius
Distribution: PCQLinux, SUSE Linux,Fedora Core 5, Fedora Core 6, Knoppix Live, Kubuntu Edgy, PCLinuxOS
Posts: 167

Original Poster
Rep: Reputation: 30
Yes thanks for you quick reply! I'll try to do what you said! Thanks to you all!
 
  


Reply

Tags
control, exit


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if an app is running and if it's not launch this app Coume Linux - General 3 07-28-2008 03:34 AM
Is there a way to launch an app so that it's not shown on the taskbar kornerr Linux - General 13 05-17-2005 11:38 PM
app launch speed newby101 Linux - General 3 11-27-2003 01:01 PM
can't launch java app from shell script... LonAllen Linux - Newbie 0 07-07-2003 09:37 AM
How to find the command line to launch app ScreeminChikin Linux - General 2 09-19-2002 12:39 AM


All times are GMT -5. The time now is 02:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration