Java Reference
In-Depth Information
Change the name of the configuration from Unnamed to
Hello World
in
the
Name
text field.
4
Click the ellipsis button (
…
) to the right of the
Main Class
text field.
Doing so causes the
Choose Main Class
dialog to appear.
5
The
Choose Main Class
dialog allows you to select the class to execute
either by name or by navigating the source tree. This project has only
one class, so finding it is simple. Click once on the class name in the list,
and then click
OK
to select it.
6
In the
Use classpath and
JDK
of module
drop-down list, select the
Hel-
loWorld
module. Doing so tells
IDEA
that it should use the
JDK
associ-
ated with the
HelloWorld
module to execute the class.
7
Uncheck the
Display settings before running/debugging
option to pre-
vent
IDEA
from showing this configuration screen every time you try to
run or debug your project.
8
Click
OK
at the bottom of the
Run/Debug Configurations
window to
execute the program. Doing so makes these options an acceptable con-
figuration that you can subsequently run and returns you to the editor.
9
Be sure the
HelloWorld
run/debug configuration is chosen in the selector
on the toolbar. To execute that configuration, select
Run | Run
. Alterna-
tively, click the
Run
button next to the configuration selector or use the
Shift+F10
keyboard shortcut.
10
Now that you've seen the long way of defining a run/debug configuration,
here's a quicker method: Right-click anywhere inside the class, and select
the
Run HelloWorld.main()
menu item. Doing so creates a temporary
run/debug configuration that can be used multiple times during the cur-
rent
IDEA
session and can also be saved permanently if necessary.
TIP
Once you give the run command,
IDEA
executes the class, and the
Run
tool win-
dow automatically opens at the bottom of the screen. This tool window is respon-
sible for displaying all the output from executed run configurations. The first line
in the window shows the command line
IDEA
used to run the class, including all
options and arguments. The last line shows that the process has exited normally
and that you're not the victim of an infinite loop. And, if all has gone well, you
should see a friendly “Hello, World!” between those two lines.