Finally and System.exit()-Will work togother?

Does finally block execute if we call System.exit() inside a try block?
try{
if(condition)System.exit(0);
finally{
System.out.println("Inside finally");
If condition is true, will finally execute?
When i tried it on jdk1.3, it's not executed.

I'm pretty sure the finally{} block will never be executed. When calling System.exit(), it tells the application to terminate immediately. Here's something you could try, if you have code that needs to run if there's been an exception or not. Sorry for the horrible code conventions.
boolean sysExit = false;
try{
if(condition){
sysExit = true;
catch(Exception e){
//Do whatever.
finally{
//Do finally stuff
if(sysExit) System.exit(status);
}

Similar Messages

  • Why won't System.exit(0)  work?

    does System.exit(0); work with an event handler?
    I'm making a quit menu button, and I want my program to quit when it is clicked...unfortunately, System.exit(0); is not working...can soemone please help?
    thanks!

    here's all mmy code......i'm really at a loss...i can't figure anything out......
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    public class SafetyMapView extends JFrame {
         // These are the tiles and buttons
         private JPanel               tiles;
         private JButton[]          buttons;
         private JCheckBox           editWallsButton;
         private JCheckBox           selectExitsButton;
         private JButton           computePlanButton;
         private JCheckBox           showDistancesButton;
         private JButton           resetButton;
         private JMenuBar          theMenuBar;
         private JMenu               fileM;
         private JMenuItem          openM,saveM,quitM;
         private JFileChooser      showIt;
         public void setJMenuBar(JMenuBar aMenuBar){theMenuBar=aMenuBar;}
         public JButton getFloorTileButton(int i) { return buttons; }
         public JPanel getTilePanel() { return tiles; }
         public JCheckBox getEditWallsButton() { return editWallsButton; }
         public JCheckBox getSelectExitsButton() { return selectExitsButton; }
         public JButton getComputePlanButton() { return computePlanButton; }
         public JCheckBox getShowDistancesButton() { return showDistancesButton; }
         public JButton getResetButton() { return resetButton; }
         public JFileChooser getJFileChooser() { return showIt; }
         public JMenuItem getOpen() { return openM;}
         public JMenuItem getSave() { return saveM;}
         public JMenuItem getQuit() { return quitM;}
         // This constructor builds the panel
         public SafetyMapView(String title, FloorPlan floorPlan) { 
              super(title);
              // Create the panel with the floor tiles on it      
              createFloorPlanPanel(floorPlan);
              // Layout the rest of the window's components
    setupComponents();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(600, 500);
    setVisible(true);
    // Create the panel to contain the buttons that display the floor plan
    private void createFloorPlanPanel(FloorPlan floorPlan) {
         // Setup the panel with the buttons
    buttons = new JButton[floorPlan.size()*floorPlan.size()];
    tiles = new JPanel();
    tiles.setLayout(new GridLayout(floorPlan.size(),floorPlan.size()));
              // Add the buttons to the tile panel
    for (int r=0; r<floorPlan.size(); r++) {
         for (int c=0; c<floorPlan.size(); c++) {
              int i = r * floorPlan.size() + c;
              buttons[i] = new JButton();
              buttons[i].setBorder(BorderFactory.createLineBorder(Color.lightGray));
              buttons[i].setBackground(Color.white);
              tiles.add(buttons[i]);
         public void setOpenHandler(java.awt.event.ActionListener x){
         /*public void setSaveHandler(java.awt.event.ActionListener x){
                   int option = 0;
                   java.io.File sel = null;
                   java.io.File[] files = null;
                   String filename = null;
                   javax.swing.JFileChooser chsr = new javax.swing.JFileChooser();
                   option = chsr.showSaveDialog(null);
                   switch (option)
                   case javax.swing.JFileChooser.APPROVE_OPTION :
                   //do something
                        a.dispose();
                        break;
                   case javax.swing.JFileChooser.CANCEL_OPTION :
                   sel = null;
                   break;
                   case javax.swing.JFileChooser.ERROR :
                   sel = null;
                   break;
                   default :
                   sel = null;
                   break;
                   chsr.setEnabled(false);
                   //do something
                   return;
                   //DO something...//
    // Here we add all the components to the window accordingly
    private void setupComponents() {
         // Layout the components using a gridbag
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints layoutConstraints = new GridBagConstraints();
    getContentPane().setLayout(layout);
    // Add the tiles
    layoutConstraints.gridx = 0; layoutConstraints.gridy = 1;
    layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 7;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layoutConstraints.insets = new Insets(2, 2, 2, 2);
    layoutConstraints.anchor = GridBagConstraints.NORTHWEST;
    layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 1.0;
    layout.setConstraints(tiles, layoutConstraints);
    getContentPane().add(tiles);
    JMenuBar myMenuBar = new JMenuBar();
    layoutConstraints.gridx = 0; layoutConstraints.gridy = 0;
    layoutConstraints.gridwidth = layoutConstraints.gridheight = 1;
    layoutConstraints.fill=GridBagConstraints.NONE;
    layoutConstraints.insets = new Insets(2, 2, 2, 2);
    layoutConstraints.anchor = GridBagConstraints.NORTHWEST;
    layoutConstraints.weightx = 0.0; layoutConstraints.weighty = 0.0;
    layout.setConstraints(myMenuBar, layoutConstraints);      
              JMenu fileMenu = new JMenu("File");
              myMenuBar.add(fileMenu);
              fileMenu.setMnemonic('F');
              JMenuItem openM = new JMenuItem("Open Floor Plan");
              fileMenu.add(openM);
              openM.setMnemonic ('O');
              JMenuItem saveM = new JMenuItem("Save Floor Plan");
              fileMenu.add(saveM);
              saveM.setMnemonic ('S');
              JMenuItem quitM = new JMenuItem("Quit");
              fileMenu.add(quitM);
              quitM.setMnemonic ('Q');
              getContentPane().add(myMenuBar);
    public static void main(String args[]){
         //try{
         new SafetyMapView("Fire Safety Routes", FloorPlan.example1());
         //catch(java.io.FileNotFoundException e){
         //     e.printStackTrace();
    I cut out the parts where all the other buttons are being added to the layout cuz it was really relaly long....

  • I bought an IPAD air from state and the screen is not working correctly and right now i'm in Egypt ,can i send my ipad to service in Egypt and the warranty will work in Egypt or what?

    i bought an IPAD air (32 gb wifi only) from USA just one month ago and the screen is not working correctly(picture attached) and right now i'm in Egypt ,can i send my ipad to service in Egypt and the warranty will work in Egypt or what?

    Have you tried a soft-reset to see if that fixes it ? You might be able to get warranty service in Egypt for your iPad, but the warranty includes :
    IMPORTANT RESTRICTION FOR iPHONE AND iPAD SERVICE.
    Apple may restrict warranty service for iPhone and iPad to the country where Apple or its Authorized Distributors originally sold the device.
    As it's wifi-only you should have a better chance of it being serviced under warranty, but there are no guarantees, it might depend upon the repairer.
    Egypt authorised service providers : https://locate.apple.com/eg/en/

  • Firefox will not open on my computer the majority of the time. If I shut down and restart it will work sometimes, but not always. This started recently in the last two weeks. Today is June 12th 2011.

    Firefox will not open on my computer the majority of the time. If I shut down and restart it will work sometimes, but not always. This started recently in the last two weeks. Today is June 12th 2011.

    See:
    * http://kb.mozillazine.org/Browser_will_not_start_up

  • I am unable to update my apps... in my purchases page it appears as "update", then a message tells me to log on with the Apple ID I purchased the app with... Well I have tried my two different accounts and neither one will work, can someone help ??

    I am unable to update my apps... in my purchases page it appears as "update", then a message tells me to log on with the Apple ID I purchased the app with... Well I have tried my two different accounts and neither one will work, can someone help ??
    And is there any way to sync all my purchases and accounts to just have one... It is a bit stupid that you dont even get a list of something of what account you may of used, or some kind of hint, so you could log on to the right account. I am really stuck ...
    Please Advise......

    You can't merge accounts. But you can check your purchase history:
    iTunes Store & Mac App Store: Seeing your purchase history and order numbers
              http://support.apple.com/kb/HT2727
    Also, what may seem stupid to you... may be a protection of privacy to others.

  • I recently had to change my email address for the Apple ID and now when the App store comes up it still asks has my old email address and no password will work.  What should I taccepts it all fine as does facetime.  Help?

    I recently changed my email address for the Apple Id and it was accepted but now when the App store comes up it still shows my old email address and no password will work.  iCloud and Facetime are fine.  Don't know why it stays there or how to alter it.

    1. Sign out of old ID
    2. Sign in with new ID
    Settings>AppStore>Apple ID

  • I bought a movie on iTunes but when I try to watch it plays back slowly with no sound.  Then the video will speed up and the sound will work for a moment then off again and back to slow motion.  I have a dell laptop running windows 7

    The description says it all.    I bought a movie on iTunes but when I try to watch it plays back slowly with no sound.  Then the video will speed up and the sound will work for a moment then off again and back to slow motion.  I have a dell laptop running windows 7

    Hi Normanwh,
    If you are having video playback issues in iTunes on your Windows machine, you may find the following article helpful:
    Apple Support: Troubleshooting iTunes for Windows Vista or Windows 7 video playback performance issues
    http://support.apple.com/kb/ts1718
    Regards,
    - Brenden

  • A friend upgraded my flash player and now nothing will work.

    I am completely computer stupid. My friend said that my flash player needed to be upgraded. He upgraded it for me and now nothing will work. Youtube, games, etc. Can someone help me fix it. Like I said I am computer stupid so I will need step by step instructions if anyone can help.

    amhinton1 wrote:
    in Windows/system32/macromed/flash is a text document called FlashInstall.
    This means that Flash Player is not installed - the required files should be in this folder.
    Download this installer http://www.adobe.com/go/full_flashplayer_win_ie; save it to disk (e.g. your Desktop), then close all browser windows and run the downloaded installer.
    What do you now have in that folder?
    Is Flash Player now enabled, and is it working?  (Check it here http://www.adobe.com/software/flash/about/)

  • My Macbook Pro keyboard AND USB keyboard will not work.  However, the trackpad and USB mouse will work.  Any help?

    My Macbook Pro keyboard and USB keyboard will not work.  However, the trackpad and USB mouse will work.  Any help?
    This is quite frustrating, since it randomly occured as I was browsing the web.  It seemed to happen out of nowhere.  I cannot login to my user account because I cannot type my password. 
    Any help will be appreciated.
    -Matt

    If you have another Mac, boot the non-working one into Target Disk Mode (holding down "T" at startup). Hook up the two Macs via a Firewire cable. The non-working one will mount on the other Mac as an external Firewire HD.
    Next, download the 10.5.6 Combo update from here:
    http://www.apple.com/downloads/macosx/apple/macosx_updates/macosx1056comboupdate .html
    Run it. When it asks you for a destination, choose the other Mac that was mounted via Firewire. When it's done, unmount the computer and restart it. The keyboard and mouse should work now.

  • Hey apple users. if i deaktivate my iphone because i got a new phone, can someome else put thier sin card in my old iphone and then it will work again? or does the phone stop working all together if i deactivate the phone on the support page?

    hey apple users. if i deactivate my iphone because i got a new phone, can someome else put thier sin card in my old iphone and then it will work again? or does the phone stop working all together if i deactivate the phone on the support page?

    Do this first:
    http://support.apple.com/kb/HT5661
    Then whoever gets the phone just sets things up again using their Apple ID.

  • My Keyboard and touch-pad will work during post, but will not work after the os loads?

    I have a G60 and My Keyboard and touch-pad will work during post, but will not work after the os loads? Im running Windows 7, Anyone have any Ideas? I have already tried a hard reset, and safe mode???

    Try pressing the fn key and f2 to reach bios
    or
    try a usb mouse from your desktop
    S70-ABT2N22 Windows 7 Pro & 8.1Pro, C55-A5180 Windows 8.1****Click on White “Kudos” STAR to say thanks!****

  • My iphone is frozen on my facebook screen and no buttons will work. Ive tried holding the lock and the home button and that doesnt work.

    My iphone is frozen on my face book screan and no buttons will work. Ive tried holding the lock and the home button but they wont work. Also my lock button is broken so i have to use assesive touch

    You've got three options: 1. Take your phone to an Apple store & do an out of warranty replacement...cost is US $149 ~ $229, depending on iPhone model; 2. A third-party repair shop ~US $50 or so; 3. "Try" restoring your phone in iTunes.

  • Java 1.5_09 vs Java 1.4.2_11 and System.exit

    The java program tries to access a url, if cannot it returns 129
    * <pre>
    * 0 - Successful connection
    * 129 - Network connection failure, or no connection.
    * 130 - Connected to server, but received HTTP error.
    * </pre>
    Here is the code snippet
    status = status == -1? 129 : 130;
    System.exit(status);
    if I compile the class under 1.4.2_11 I get back 129. If I compile the class under 1.5_09 I get back -107374189
    This causes my bat file errorlevel check to fail. Any ideas ?

    Hello nudli and Welcome to Apple Discussions ..
    In laymans terms, Java SE consists of a virtual machine, which must be used to run Java programs, together with a set of libraries (or packages) needed to allow the use of file systems, networks, graphical interfaces, and so on, from within those programs. Java works quietly in the background.
    First, run the Software Updater to see if you have all available updates. Click the Apple logo top left in your Desktop then click Software Update ... the update window will open and populate a list of updates you might need. Just follow the instructions to install them. If the Software Updater didn't find any needed Java files, then you are up to date. Most times after an install you need to Restart. AND, it's always good to run Disk Utility located here: Applications/Disk Utilities and Repair Disk Permissions every time you update software on your Mac.
    Go to this link to see minimum requirements needed to upgrade to Leopard 10.5:
    http://www.apple.com/macosx/techspecs/
    Carolyn

  • Kill and System.exit

    Is there a way (with Linux) to issue the kill command on your java process so that System.exit(0) is called and you know that your shutDownHooks will run?

    Thanx again for the reply, Freddy
    first things first:
    System.exit(0) does not work in this case..
    and the code is reached..
    // main class
    public class AdminApp {
    public AdminApp() {
    public static void main(String[] args) {
    AdminApp adminApp1 = new AdminApp();
    AdminFrame frame = new AdminFrame();
    /// admin frame class
    public class AdminFrame extends JFrame{
    public AdminFrame() {
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    this.pack();
    this.setSize(600,480);
    this.setVisible(true);
    groupsMenuItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    desktop.add(new AdminGroups());
    //admingroups class
    public class AdminGroups extends JInternalFrame {
    private JTextArea textArea = new JTextArea();
    private JScrollPane scrollPane = new JScrollPane();
    JPanel groupPanel = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    public AdminGroups() {
    setSize(200,300);
    setTitle("Edit Text");
    setMaximizable(true);
    setIconifiable(true);
    setClosable(true);
    setResizable(true);
    scrollPane.getViewport().add(textArea);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(scrollPane,BorderLayout.CENTER);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    getContentPane().add(groupPanel);
    private void jbInit() throws Exception {
    groupPanel.setLayout(xYLayout1);
    }

  • Looking for shelf system that will work with 5th gen 8g Nano?

    Hi,
    I'm looking for a shelf stereo system with integrated iPod dock that will work with my 5th gen 8 gig Nano that I received as a gift. I've been researching this and have a found a few candidates such as the JVC UX-GN8 or UX-LP5, or the SONY CMT-BX20i. But... have been unable to confirm if they work with this new 5th generation model. Anyone have one of those units, or something similar, that works? Also, is it true that the Apple Cradle ($49.99+cable) has some problems docking the 5th generation Nano in the sense that all the features are not accessible (audio, video, etc.)? Thanks for any and all responses.

    have been unable to confirm if they work with this new 5th generation model.
    If their websites do not specifically state that their product works with the *iPod Nano 5th Generation _with video,*_ its more likely their product is not compatible. You can try calling them if possible to confirm.
    Have you checked MacMall's website?

Maybe you are looking for

  • Error message when trying to update from 4.1 to 4.2

    I went to update my iphone4 to 4.2 from 4.1 and got the following message: "There are purchased items on the iPhone that have not been transfered to your iTunes library. You should transfer these items to your iTunes library before updating this iPho

  • Laserjet p1102w wifi issue

    Have been trying to setup my HPLaserjet P1102w printer into my network but the wifi button on the printer doesnt seem to activate even when i press after following manuals provided. I have removed and reinstalled the software and drivers a couple of

  • Acount activation issues for a new hard drive immage

    I have recently gotten my office PC updated to Win 7 with a fresh install and newly installed iTunes 10. When i try to activate iTunes I get the prompt to activate it. So far so goo. However when I enter my password and hit activate I get a follow up

  • Lock Screen Image

    Hi, I am using Nokia Lumia 920 and have set the Lock screen to take pictures from Custom Facebook Folders. But this is not happening. It shows a Black empty screen when I try to unloack the device. I verified that the Mobile data is active and Facebo

  • Project Profile for templates CJ91

    Hi , I am an SD consultant and quite new to PS. Please execuse if my question is basic.     When i am creating a template in transaction CJ91 system is defaulting the "Project Profile (Proj-PROFL)  " value as  "DPSC1"  and that filed is in grey mode.