Using Surround with Try/Catch
To surround a statement or a set of statements with a try/catch block:
-
In the Java editor, select the statement or a set of statements that you
want to surround with a try/catch block.
-
Do one of the following:
-
From the menu bar, select Source > Surround with try/catch or
-
From the editors pop-up menu, select Source > Surround with try/catch
block
-
'catch' blocks for all uncaught exceptions (if there are any) are created.
If there are no uncaught exceptions, a dialog appears informing you about
this fact and asking if you want to create a 'catch' block for java.lang.RuntimeException.
Java editor
Using the Java editor
Using Structured Selection
Source menu