blob: e0c42af4b8d0c4f7adcf06b15cca8d8100968a39 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="copyright" content=
"Copyright (c) IBM Corporation and others 2000, 2011. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type=
"text/css" />
<title>
Launching a Java program in debug mode
</title>
</head>
<body>
<h1>
Launching a Java program in debug mode
</h1>
<p>
Launching a program in debug mode allows you to suspend and resume the
program, inspect variables, and evaluate expressions using the debugger.
</p>
<p>
To launch a Java program in debug mode,
</p>
<ol>
<li>In the <strong>Package Explorer</strong>, select the Java compilation
unit or class file with the main method you want to launch.
</li>
<li>Press the <strong>Debug</strong> [ <img src=
"../images/org.eclipse.debug.ui/etool16/debug_exc.png" width="16"
height="16" alt="The Debug button" /> ] button in the workbench toolbar
or select <strong>Run &gt; Debug</strong> from the workbench menu bar.
Alternatively you can select <strong>Run &gt; Debug As &gt; Java
Application</strong> from the workbench menu bar, or select
<strong>Debug As &gt; Java Application</strong> in the <strong>Package
Explorer</strong> pop-up menu or in the drop-down menu on the
<strong>Debug</strong> tool bar button.
</li>
<li>Your program is now launched and the launched process appears in the
Debug view.&nbsp;
</li>
</ol>
<p>
If you want your program to stop in the <em>main</em> method so that you
can step through its complete execution, create a <strong>Java
Application</strong> launch configuration and check the <strong>Stop in
main</strong> checkbox on the <strong>Main</strong> tab.&nbsp;
</p>
<p>
You can also debug a Java program by selecting a project instead of the
compilation unit or class file.&nbsp; You will be prompted to select a
class from those classes that define a <em>main</em> method.&nbsp; (If
only one class with a main method is found in the project, that class is
launched as if you selected it.)
</p>
<p>
<img border="0" src="../images/ngrelc.png" alt=
"Related concepts" /><br />
<a href="../concepts/concept-java-views.htm">Java views</a><br />
<a href="../concepts/concept-java-editor.htm">Java editor</a><br />
<a href="../concepts/cdebugger.htm">Debugger</a>
</p>
<p>
<img border="0" src="../images/ngrelt.png" alt="Related tasks" /><br />
<a href="task-remotejava_launch_config.htm">Connecting to a remote VM
with the Java Remote Application launcher</a><br />
<a href="task-relaunch_program.htm">Re-launching a program</a><br />
<a href="task-running_and_debugging.htm">Running and debugging</a><br />
<a href="../tasks/tasks-executionArgs.htm">Setting execution
arguments</a><br />
<a href="task-stepping.htm">Stepping through the execution of a
program</a><br />
</p>
<p>
<img border="0" src="../images/ngrelr.png" alt=
"Related reference" /><br />
<a href="../reference/views/debug/ref-debug_view.htm">Debug
view</a><br />
<a href="../reference/views/ref-view-package-explorer.htm">Package
Explorer</a><br />
</p>
</body>
</html>