5
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
2 |
<cheatsheet title="Create a Hello World application">
|
|
3 |
<intro href="/org.eclipse.platform.doc.user/reference/ref-cheatsheets.htm">
|
|
4 |
<description>
|
|
5 |
This cheat sheet shows you how to create the famous "Hello World" application and try it out. You will create a Java project and a Java class that will print "Hello world!" in the console when run.<br/>
|
|
6 |
<br/>
|
|
7 |
If you need help at any step, click the (?) to the right. Let's get started!
|
|
8 |
</description>
|
|
9 |
</intro>
|
|
10 |
<item title="Open the Java perspective" dialog="false" skip="false" href="/org.eclipse.platform.doc.user/concepts/concepts-4.htm">
|
|
11 |
<description>
|
|
12 |
If you're not already in the Java perspective, in the main menu select <b>Window</b> > <b>Open Perspective</b> > <b>Java</b> or click on the "Click to Perform" link below.
|
|
13 |
</description>
|
|
14 |
<command serialization="org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.jdt.ui.JavaPerspective)" required="false" translate="">
|
|
15 |
</command>
|
|
16 |
</item>
|
|
17 |
<item title="Create a Java project" dialog="true" skip="false" href="/org.eclipse.jdt.doc.user/concepts/concept-java-project.htm">
|
|
18 |
<description>
|
|
19 |
Before creating a class, we need a project to put it in. In the main toolbar, click on the <b>New Java Project</b> button, or click on the link below. Enter <b>HelloWorld</b> for the project name, then click <b>Finish</b>.
|
|
20 |
</description>
|
|
21 |
<command serialization="org.eclipse.ui.newWizard(newWizardId=org.eclipse.jdt.ui.wizards.JavaProjectWizard)" required="false" translate="">
|
|
22 |
</command>
|
|
23 |
</item>
|
|
24 |
<item title="Create your HelloWorld class" dialog="true" skip="false" href="/org.eclipse.jdt.doc.user/gettingStarted/qs-9.htm">
|
|
25 |
<description>
|
|
26 |
The next step is to create a new class. In the main toolbar again, click on the <b>New Java Class</b> button (or the link below). If not already specified, select <b>HelloWorld/src</b> as the source folder. Enter <b>HelloWorld</b> for the class name, select the checkbox to create the <b>main()</b> method, then click <b>Finish</b>.<br/>
|
|
27 |
<br/>
|
|
28 |
The Java editor will automatically open showing your new class.
|
|
29 |
</description>
|
|
30 |
<command serialization="org.eclipse.ui.newWizard(newWizardId=org.eclipse.jdt.ui.wizards.NewClassCreationWizard)" required="false" translate="">
|
|
31 |
</command>
|
|
32 |
</item>
|
|
33 |
<item title="Add a print statement" dialog="false" skip="false" href="/org.eclipse.jdt.doc.user/concepts/concept-java-editor.htm">
|
|
34 |
<description>
|
|
35 |
Now that you have your HelloWorld class, in the <b>main()</b> method, add the following statement:<br/>
|
|
36 |
<br/>
|
|
37 |
System.out.println("Hello world!");<br/>
|
|
38 |
<br/>
|
|
39 |
Then <b>save</b> your changes; the class will automatically compile upon saving.
|
|
40 |
</description>
|
|
41 |
</item>
|
|
42 |
<item title="Run your Java application" dialog="false" skip="false" href="/org.eclipse.jdt.doc.user/gettingStarted/qs-12.htm">
|
|
43 |
<description>
|
|
44 |
To <b>run</b> your application, right-click on your class in the Package Explorer and select <b>Run As</b> > <b>Java Application</b>. The <b>Console</b> view should appear at the bottom and display the "Hello, world!" output.<br/>
|
|
45 |
<br/>
|
|
46 |
Congratulations! You have successfully created a Hello World
|
|
47 |
application!
|
|
48 |
</description>
|
|
49 |
</item>
|
|
50 |
</cheatsheet>
|