Is there any way to listen for OS-commands like LINUX/UNIX "kill myApp"?

Hello, world! ;)
I would like to get help on the following problem:
Situation:*
Implementing my first server-daemon I was wondering if there is any way to listen for OS commands/events affecting the application.
One particular handling I intend to implement is after an OS termination command (like *"kill myDaemon.jar"* on LINUX/UNIX) to shut down the daemon.
This would be really helpful, because in this way I would not just shut down the daemon brutally but being able to handle an event like this to shutdown the Thread pool, send all connected peers that the server/daemon will be down for a while, close all connections ...
Need help:*
Am I completely forgetting something which solves this problem really quick? :D
Is there any Listener Interface which I can use to achieve this?
Is maybe the JVM/JRE handling this and running garbage collectors?
Is there any site/tutorial/... focusing on problems like this?
Thanks in advance for any help on this subject!
JAVAnetic

Thanks, this was indeed very helpful.
I implemented a shutdownHook and it works like I hoped it would:
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
      @Override public void run() {
        // shut down commands
    }));After typing *"kill process_ID"* in a terminal the shutdownHook is invoked (like mentioned before) and the shut down commands are executed.
Works fine.
Am happy. :D

Similar Messages

  • Is there any way to listen to Ipod touch  4 through my car stereo?

    Is there any way to listen to my Ipod Touch 4 through my car stereo?

    Yes.  Here is a link to a really inexpensive car charger/fm transmitter for your iPod.
    http://www.amazon.com/Wireless-FM-Transmitter-Adapter-Charger/dp/tech-data/B002Y AOS7A

  • Is there any way to search for a term using the Firefox search field, and have the results automatically open in a new tab?

    Is there any way to search for a term using the Firefox search field, and have the results automatically open in a new tab? When there was support for Google Toolbar, I was able to do this; now, whenever I want to search for something, I have to open a new tab to do it, and cut-and-paste my search into the search field in the new tab. I used to be able to highlight, drag, and drop something into the search field and have it automatically open in a new tab. This is enough for me to switch to Chrome . . .

    Set a preference to have searches from the Search Bar (upper right) automatically open all searches in a new tab
    #type '''about:config''' in the URL/Location/Address bar and press the Enter key
    #if you see a warning, accept it (promise to be careful)
    #Filter = '''browser.search.openintab'''
    #in the lower panel, double click the item (or right-click and choose "Toggle") to change the value to "true"
    #close the about:config tab and test
    #See:
    #*For help with opening/using about:config, also see: http://kb.mozillazine.org/About:config
    #*Also see: http://kb.mozillazine.org/About:config_entries (click on "Browser", scroll down to browser.search.openintab)
    '''Search Bar''': http://support.mozilla.com/en-US/kb/Search+bar
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    About Google toolbar............
    Google decided that they will no longer produce the Google Toolbar for Firefox 5 and newer version. It is best to move on to other alternatives than to try any "hacks" to the toolbar that may or may not perform in the future. Future versions of Google toolbar will only work with IE7-9. Google Toolbar is not available on any other browser, even Google's own browser.
    *http://googletoolbarhelp.blogspot.com/2011/07/update-on-google-toolbar-for-firefox.html
    *https://support.mozilla.com/en-US/kb/google-toolbar-not-compatible-firefox?s=google+toolbar&r=0&as=s
    *http://www.google.com/support/toolbar/bin/answer.py?answer=1342452&topic=15356%29
    *Google Toolbar 8 FAQ (IE only): https://www.google.com/support/toolbar/bin/answer.py?hl=en&answer=1111588
    '''''To access your Google Bookmarks visit''''' www.google.com/bookmarks.
    Alternatives:
    *http://kb.mozillazine.org/Using_Google_Toolbar_features_without_toolbars
    *https://addons.mozilla.org/en-US/firefox/addon/googlebar-lite/
    *https://addons.mozilla.org/en-US/firefox/addon/gbookmarks-google-bookmarks-fo/

  • I have a 2012 iMac, running OS X Yosemite 10.10.2. Is there any way to scan for malware without buying a program?

    I have a 2012 iMac, running OS X Yosemite 10.10.2. Is there any way to scan for malware without buying a program?

    Have you been having some problems that make you think you may have malware installed?
    Download and run Etrecheck.  Copy and paste the results into your reply. Etrecheck is a diagnostic tool that was developed by one of the most respected users here (and recommended by Apple Support personnel) in the ASC to help identify the more obvious culprits that can adversely affect a Mac's performance.

  • Is there any way to search for bad blocks in my Macintoshi HD without formating it? I'm experiencing too much I/O problems...

    Is there any way to search for bad blocks in my Macintoshi HD without formating it? I'm experiencing too much I/O problems...

    Check the drive health with the free demo of SMART Utility.
    http://www.volitans-software.com/smart_utility.php
    Reformatting and zeroing out might keep a drive going a bit longer, but once bad blocks become noticeable, it's not a drive you should trust any longer.

  • Is there any way to get windows environment variables like %USERNAME% with javascript?

    is there any way to get windows environment variables like %USERNAME% with javascript using Adobe 10 pro?

    There is a fair amount of Acrobat JavaScript and Acrobat knowledge need to sort all of this out.
    The identity object holds a lot of sedative information. First, upon installation of Acrobat, only the login name is available in the identity object and the end user of the application needs to complete the "Name", "email" and "Organization Name" in the application's preferences. These are the only fields that are available to Acrobat JavaScript identity object as corporation, email, loginName, and name.
    Using the instructions in The Acrobat JavaScript Console (Your best friend for developing Acrobat JavaScript) you can run the following script in the JS console to see the items of the identity object:
    for(i in identity) {
    console.println(i +": " + identity[i]);
    and the following will appear in the console:
    loginName: georgeK
    name: George Kaiser
    corporation: Example
    email: [email protected]
    true
    The documentation states you need to use a trusted function to access this data, but you can access it at startup of Acrobat/Reader and add the properties of the identity object to an array:
    // application variable to hold the properties of the identity object
    var MyIdentity = new Array();
    // loop through the properties of the identity object
    for (i in identity) {
    // place each property of the identity object into an element of the same name in the Identity array
    MyIdentity[i] = identity[i];
    console.println(i +": " + MyIdentity[i])
    You access the items with:
    var loginUser = MyIdentity[loginName];  // get the loginName property
    In the user application level JavaScript file. See Acrobat Help / User JavaScript Changes for 10.1.1 (Acrobat | Reader) for the location of the application level folder you need to use.
    I would change the name of the array used in this post so an untrusted user cannot get to your data. Some of this data can be used in hacking into a user's system.

  • Is there any way to "resore" a previous backup, like from a different day?.....like a restore on my pc?????

    Is there any way to "resore" a previous backup, like from a different day?.....like a restore on my pc?????

    Here's one:  SMS Export Plus - Backup SMS and iMessages to your PC in excel file format on the App Store on iTunes
    Just Google iPhone SMS backup and you'll get all kinds of options.

  • Is there any way to listen to music WITHOUT using the speakerphone or headphones?

    I listen to streaming talk radio in my car, I usually have drive to and walk in and out of several office buildings throughout my day. I would like to be able to just put my BB up to my ear and pretend like I am listening to someone talk on the phone, when I'm really listening to the radio. Is there any way to do this? I hate having to fumble around with headsets every time I stop, and obviously I cant walk through a office building with the loud speakerphone/built in speaker blasting.

    Sure there is.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Is there any way to wait for a value without using JDialog or JOptionPane?

    I am implementing a dictionary program by detecting word in a JTextPane and asking a user to choose one of available meanings from JOptionPane or JDialog. The program runs under a while-loop until all dictionary words are detected or a user clicks cancel.
    However, I don't want to use JDialog or JOptionPane because it is sometimes annoying to have a popup window on every detected dictionary word.
    So, I use JList with Buttons on the same Frame as the JTextPane. However, now, the program does not stop when it detects a dictionary word. It just uses a default value of the JList for translating word to meaning.
    Is there any way I can simulate the JDialog or JOptionPane without using it?
    I mean I'd like to stopp the program temporary, wait for an answer from other components, and then continue to detect the next dictionary word.
    Thank you.

    I'm probably reading this all wrong, but instead of the while loop,
    the method just looked for a dictionary word from a particular caretPosition,
    so, to start, it would be findWord(0)
    when found, add whatever to wherever, note the caretPostion at the end of the 'found' word, and method returns.
    when the user selects whatever button, the button's actionListener also calls the method again, using the noted caretPosition
    findWord(42);
    so, it starts searching from 42 (instead of the start)
    basically it is event driven
    findWord sets the button/s
    click a button starts findWord

  • Any way to listen for changes in Spark TextArea?

    Hello,
    What is the best way to listen for changes in a Spark TextArea? My scenario is simple: I need to know when some text is added or deleted (with from/to index).
    Regards,
    Dinko

    s:TextArea does have a chang event - http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/TextAr ea.html.

  • Is there any way to create a setup file Like Visual Basic

    Hi,
    I want to create a setup file of all developed foms and reports to install them to desireable location, is there any way to create a setup file in oracle, Like Vb.
    Raza

    I believe there is something from Oracle but it was frustratingly buggy when I used it a few years back and only worked via the Oracle installer.
    Personally, I'd recommend something like Innosetup, which is freeware and a Windows-style installer much like InstallShield etc. so it'll create an executable setup file probably OK if they've already got the Oracle Runtime components installed.

  • Is there any way to reappear my missing application(like faceboook,twitter) icon?

    can you guys help me?most of my icon missing suddenly. it even doesn't show in itunes when i sync the phone. when i check with ifile, all the missing apps were still in my iphone. Is there any way to reappear the icon back?i have try reset the home screen and check the restriction but no luck.

    Restoring a jailbroken phone does not always fix things.
    You are on your own. You jailbroke your phone, you fix it.

  • Is there any way in Firefox for android to use native handlers?

    In Firefox for windows or Linux, I can register a URL handler (e.g. mailto:) but android takes this to a new level with intents which can register responders for individual URIs as well as for and mine types.
    Are there any plans to natively support android intents (e.g. to handle a transition from twitter.com to the native twitter app), or perhaps an add-on to support something similar? I have already found https://addons.mozilla.org/en-US/android/addon/open-native-app/ but it's a manual process, rather than an automatic one.

    http is a website, Firefox browses websites. We are not planning on kicking people to the native app for such things. We do support loading resources that list helper apps. For example if you load a Google Maps page there is an Android icon in the address bar that will take that page info and pass it to the Google Maps app.

  • Is there any way to register for changes in a NetworkInterface?

    Greetings. I'm interested to know if there's a way to register for changes to a NetworkInterface. Changes could include ifup/ifdown, a change in the displayable name, adding/removing InterfaceAddress or InetAddress, or even a change in the hardware address. It doesn't look like it but I thought I'd check.
    Thanks. Jerry.

    The latest version of software for your iPod is shown in the iPod's Summary screen in iTunes.  If an update is available, notification will be there.  If it says "Your iPod software is up to date," you have the latest software.

  • Is there any way to use a "filmstrip" effect like FCPro X has?

    We use both FCP 7 & X.  Does anyone know, are there any third parties, or Apple for that matter, that would allow us to create the filmstrip transition or effect that we see in X?  They hae a Pan down in X that looks pretty neat.
    Any similar type effects available in FCP 7?
    Thanks,
    Larry

    Just an idea: how about if you master the part the way you want (just the one track - nothing else), export it to iTunes, and then reintroduce the already mastered effect as one track on the next phase of the project?

Maybe you are looking for

  • Datagrid Image Renderer Broken in CS SDK but not Flex project

    Within a Photoshop Extension, I have a DataGrid which has an inline custom image renderer whose dataprovider is an ArrayCollection called "photos"  representing a list of photos and some metadata properties.  One of the properties "fileName" is conca

  • Installing Adobe Reader error code 1328

    Installed what I thought to be Adobe Reader but it was not.  It was a paid site displaying Adobe Reader. Now when down loading and attempting to install the correct Adobe Reader I receive an error code 1328.  Error applying patch to file C:\config.Ms

  • Does anyoneone know where I can get the dmg 10.4.3 combo

    Does anyoneone know where I can get the dmg 10.4.3 combo I tried downloading it from Apple site but the link brought me to latest updates instead Thanks

  • LOVE my video iPod, but I have a question on battery life

    I just received my iPod yesterday, and I already have my entire music library on it as well as 3 movies and I must say I am amazed... One question though, after watching "Stealth" for about 20 minutes, the battery appears to be halfway drained. Is th

  • Do we have to separate java source files and class files after compiled..

    Hi, I really confussed with this: I have compiled java source files into a package and tried to use but the classes can not be found. Should I separate class and source files after compiled with packages names. I hope you understand what i mean. Than