How do you exit an application :) very simple question

Hi Everyone
how do you exit an application.
For example let's say I had something like this
public class MyClass implements Runnable{
public static void main(String[] ar){
MyClass mc = new MyClass();
Thread t = new Thread(mc);
t.start();
public MyClass(){
get a file
but if the file is not found Exit the application
public void run(){
while(true){
// do something interesting that depends on the properties of that file
now I can make the try catch(FileNotFoundException e ) block in constructor . I can return from the constructor BUT public static main(String[] arg) will continue to execute and start the new thread .
So the application will enter the run() method and throw some errors.
I know i could simply set a variable in the catch block and test it to determine if the various methods will return but that doesn't seem reasonable --- anyone have a suggestion -- especially if I have lot's of classes and threads working at the same time
thanks
stev
In the catch block
}

thank you. both of those answers sound great.
it seems that I should actually understand the correct use of the constructor.
Perhaps the constructor should just be used to set variable names -- and not to perform so many actions like loading property files .
it seems like loading property files can better organized and implemented as a separate method which is called by the run method.
When the exception is thrown then i think i can more gracefully exit the application in the run method. And this solution can be used for classes that extend Thread and classes that call start() from the outside of the class
stev

Similar Messages

  • Very simple question, how do you configure windows 8.1 to use a SF card as the default install location for software applications?

    Very simple question, how do you configure windows 8.1 to use a SD card / external drive as the default install location for software applications? Primarily interested in apps installed from the windows store. This should be available in the settings
    charm within the windows store. This must have been overlooked in the development of windows 8.1 or is a bug.
    Regards, Bill
    * update
    I've tried modifying this key and the path:
    “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx”
    http://answers.microsoft.com/en-us/windows/forum/windows_8-windows_store/how-do-you-install-apps-in-windows-8-from-the/c4fbe2a8-fd3d-41c1-b9a6-6f881eed374f
    Also tried using symlinks as detailed here:
    http://social.technet.microsoft.com/Forums/windows/en-US/8eee52c2-db0f-4032-8c72-7cd999e8b41a/windows-8-apps-installing-to-secondary-drive?forum=w8itprogeneral

    Here's some links I've used to try to figure this out:
    http://social.technet.microsoft.com/Forums/windows/en-US/2dfc0cd9-7d1b-41de-abce-e03fb6a5a383/metro-apps-not-working-in-windows-8-pro-x64-after-moving-users-and-programdata-folders?forum=w8itproinstall
    http://social.technet.microsoft.com/Forums/windows/en-US/8eee52c2-db0f-4032-8c72-7cd999e8b41a/windows-8-apps-installing-to-secondary-drive?forum=w8itprogeneral
    http://social.technet.microsoft.com/Forums/windows/de-DE/f5e33ac9-beab-4b99-b3ca-7cb5e6f415e4/how-do-you-change-metro-apps-default-install-location?forum=w8itprogeneral
    Regards, Bill
    The registry method does not work with 8.1.  I found this out the hard way.  Doing it on 8.1 will leave you reinstalling the OS if you didn't do a SRP beforehand.

  • This is a very simple question,but I don't know.Please me.Thank you!

    I am a Chinese student in a university.I have a very simple question to ask.
    I have writed a EJB module,and I have deployed to Weblogic8.1 successfully.
    1.Now I want to write a client program.Is it necessary that the client program is packaged in the EJB package.For example ,the EJB package is Beans,is "package Beans " or "import Beans.*" necessary in my client program.
    2.If I only know the EJB interfaces,that means the EJB module is writed by other programer.I want to know how I can write the client program.How can I call EJB module's method writed by other programer.Could you give me a simple example?
    Thank you very much.

    I have writed a EJB module,and I have deployed to
    Weblogic8.1 successfully.:-)
    1.Now I want to write a client program.Is it
    necessary that the client program is packaged in the
    EJB package.For example ,the EJB package is Beans,is
    "package Beans " or "import Beans.*" necessary in my
    client program.You need not package your client with the EJB. It can be a JSP/servlet or a stand-alone application.
    2.If I only know the EJB interfaces,that means the
    EJB module is writed by other programer.I want to
    know how I can write the client program.How can I
    call EJB module's method writed by other
    programer.Could you give me a simple example?
    import java.util.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import examples.*;
    class TestEJBHello {
        public static void main(String[] args) {
            Context context   = null;
            Object object     = null;
            // Hashtable for environment properties.
            Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
            env.put(Context.PROVIDER_URL, "t3://localhost:7001");
            HelloHome home            = null;
            HelloWorld hello          = null;
            try {
                context     = new InitialContext(env);
                object      = context.lookup("HelloWorldTest");
                System.out.println(" JNDI Looked up >>> " +object);
                home        = (HelloHome)PortableRemoteObject.narrow(object, HelloHome.class);
                hello       = home.create();
                System.out.println(hello.hello());
            } catch(Exception e) {
                e.printStackTrace();
            } finally {
                close(context);        // Closes the initial context.
        private static void close(Context context) {
            try {
                context.close();
                System.out.println("*** Context closed. ***");
            } catch (NamingException namingException) {
                namingException.printStackTrace();
            } catch(Exception exception) {
                exception.printStackTrace();
    }Here's a sample client app code I use for a HelloWorld EJB. You need to have a EJB client JAR containing the home and remote interfaces in the classpath during compile time and runtime.
    x

  • How do you exit a frozen program, trying to open an exel

    how do you exit a frozen program, trying to open an exel not realizibg my new mac book pro has no such software installed, .i keep getting the pretty color spinning wheel

    As a very last resort, you can hold the power button for 10 seconds to force-stop the entire system.  But stopping all processes (even the normal OSX routines "write" operations) can leave your system in need of file-system (but not HD physical) repair.

  • HT4753 I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    It's actually even easier than using Save As to see the full path to the currently open document. Just do a "Secondary click" on the document title in its window's title bar.
    Like you, I relied upon Save As my whole life to check a file's location and considered it a must-have capability. Turns out it's even faster to use the single-click method to reveal the full path to the open document. It displays the entire path to the current document starting from the level of your Mac, and works for files stored on drives as well as iCloud.
    If you're not sure how to do a secondary click, go into System Preferences, select Trackpad, Point & Click to find the current preference for secondary click on your Mac. If you happen to have a mouse with more than one button, it's probably the right button. As a trackpad user, I check the box to "Click or tap with two fingers," so a simple two finger tap on the title of an open document reveals its full path. This feature actually has been around for a very long time.
    Note that this is not the same thing as the Autosave and Versions menu, which is exposed using a little drop down triangle to the right of the title. There is no visual clue for the presence of this feature - you just have to know it's there, probably because this feature goes all the way back to pre-OS X days.

  • How do you fully close applications?

    How do you fully close application that have been opened?  My battery life does not seem to be very long, so I am thinking that applications must still be running that I am unaware of.

    Double tap the home button to bring up the multi-tasking bar, tap & hold the app icon until they all start to wiggle, tap the red minus sign, tap the home button when finished.

  • HT3597 How do you exit voice control on iPhone 4, with iOS7.1.1?

    How do you exit voice control on iPhone 4, with iOS7.1.1?

    capsjenwalker wrote:
    How do I disable Voice Control all together on a 4?
    Sorry, you can't. There is no setting to completely disable such.

  • How do you add an application event to the Applications Panel

    How do you add an application event to the Applications Panel.
    My previous post referred to .ashx files, and the problem seems that Firefox, by default, does not recognize a .ashx format being read by Adobe Acrobat.
    Therefore there needs to be a way to add Applications and Events into the Applications Panel under Preferences

    domdp wrote:
    ...I have Theme L selected and I get 10 icons along the left side and bottom....
    ...I am thinking I may be limited to 10 icons....
    Gotcha... But actually its limited to 9 icons in the L theme as the Profiles icon is always present. From that screen hit the Menu key to display the bigger list of icons. Arange them so the first 9 icons are the ones you want to see on the L theme.

  • How do you download the application???????  It says to pick an application to download??? What?

    How do you download the application?   After I hit download, It says to pick an application to download.  That doesn't make sense. 

    Norma Jeanne,
    This may be one for this specialized forum (where you may be able find the answer from previous threads),
    http://forums.adobe.com/community/download_install_setup
    or for Customer Care (tick I Still Need Help and hope for an agent available for a chat),
    http://helpx.adobe.com/contact.html?product=illustrator&topic=downloading-installing-and-s etting-up
    or for Adobe Support (phone),
    http://helpx.adobe.com/adobe-connect/adobe-connect-phone-numbers.html

  • How do you make an application open on a specific monitor?

    How do you make an application open on a specific monitor? I have two monitors, and I was able to get Firefox to open on the secondary display always by resizing it with the option or command key [I forget which one] and then quitting it. Now everytime I start it, it opens on the second monitor.
    However, when I try to do the same with QuickTime [when playing videos], it always opens on the primary display no matter what I do with it. How do I make it always open on the secondary display?
    Thanks in advance for any help!

    Thanks for the suggestion, but no, Spaces is not what I want. I have two physical monitors, and simply want an application to always open on one monitor, not be able to switch back and forth between different desktops.

  • How do you set the application directory to be constant in a project?

    Hello,
        How do you make the application directory to be same all the time? Every time I create a executable I want to be able to have the executable in the same directory all the time.
    Regards,
      Kaspar
    Regards,
    Kaspar

    Do you mean the path that the application builder puts your executable?
    Please mention the version of LV you're using or post a screenshot of your attempt, screenshots differ for LV versions.
    André
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • How do you exit a program or ap on the iPad mini?

    How do you exit an ap or program on the iPad mini?

    Tap the X (see top left)
    http://i1224.photobucket.com/albums/ee374/Diavonex/Album%203/3867644ff823d342a6b fc9d866a2e861.jpg

  • How can you view an application to a car head unit

    how can you view an application to a car head unit ( example) is the Motion X GPS

    What do you mean car head unit? Like another display?
    If you mean another display, it would only be supported by that specific app and car.

  • How do you deploy FMS applications on the web?

    Hi
    I am new to Flash Media Server and I can't get my head around
    this software.
    How do you deploy the applications you build on your
    development pc, onto an external server?
    Do you have to have FMS running on the external server?
    Or does FMS supply you with files that can be used on any
    server?
    This is so confusing.
    Thank you for any help in advance.
    Jay

    The key thing to understand is that the Flash client (the
    flashplayer) is what makes the connection to FMS. FMS and the .swf
    don't need to be on the same server.
    What you need to do is change your RTMP string in your
    connect command. I"m guessing you're currently using localhost or a
    LAN IP. Once you move the .swf to another server, you have to use
    the WAN IP or domain name of the FMS server.
    Once you have that taken care of, you can serve the .swf from
    anywhere.

  • How do you exit the Arch Linux installer?

    How do you exit the Arch Linux installer? I decided to install windows before installing Arch Linux because I want to dual-boot/with those operating systems.
    What command should I type to exit & eject my Install CD?

    reset button?
    I think it depends on far into the process you are, if you are formatting the drive anew then it shouldn't matter much when, where, or how
    Best of Luck,
    Pat Jr.
    Last edited by PatJr (2009-01-21 14:49:42)

Maybe you are looking for