1 |
This tutorial shows you how to create a Java
project, a package, and source files for a Hello World application. |
Show title, Creating a Hello World Java
application while showing WebSphere Developer Tools after starting
the product for the first time. |
2 |
To begin, select File > New > Project to
open the New Project wizard. |
Show the cursor select File > New > Project. |
3 |
In the New Project wizard, select Java
Project > Next to make a Java project. |
Show the cursor select Java Project
> Next in the New Project wizard. |
4 |
Give the project a name. For Project
Name, type MyJavaProject and select Finish. |
Show MyJavaProject typed
for Project Name and then the cursor select Finish in
the New Project wizard. |
5 |
If prompted, select Yes to
open the Java perspective. |
Show the cursor select Yes in
the Open Associated Perspective? dialog. |
6 |
The contents of the Java project are shown in
the Package Explorer view. |
Show the cursor, in Package navigation tree,
expand My Java Project to see src and JRE
System Library [jdk] directories. |
7 |
Now that you have a Java project, create a Java
package. Select New > Package. |
Show the cursor select New > Package to
open the New Java Package wizard. |
8 |
In the New Java Package wizard, type myPackage for Name and
select Finish. |
Show myPackage typed
for Name and then the cursor select Finish in
the New Java Package wizard. |
9 |
Next, create a Java class named HelloWorld.
Select New > Class. |
Show the cursor select New > Class to
open the New Java Class wizard. |
10 |
In the New Java Class wizard, type HelloWorld for Name and
select Finish. |
Show HelloWorld typed
for Name and then the cursor select Finish in
the New Java Class wizard. |
11 |
A new file, HelloWorld.java,
opens in the Java editor. |
Show HelloWorld.java in
Java editor with class definition: package myPackage;
public class HelloWorld {
}
|
12 |
Add code that will display the words Hello
World. Notice that when you start adding the code, a red marker
displays in the margin next to the first word, public. Place
your cursor over the marker to read the error messages. |
Show public typed in
the HelloWorld class, the cursor hover over the red marker, and then
the message:Multiple markers at this line
- Syntax error, insert "enum identifier" to complete EnumHeader
- Syntax error, insert "EnumBody" to complete ClassBodyDeclarations
|
13 |
The code to add is a main method
that prints out a string of characters, Hello World. The
editor provides content assistance for known Java structures. Double-click
a structure to add it.
|
Show the beginning of the main method typed
into the editor:public static void main(String[] args) {
System.
} A red line underlines System. and a
list displays. The cursor double-clicks on out - PrintStream - System
|
14 |
Select an available Java structure to see its
description. |
Show cursor click on println in
a list to display its description and then double-click on println to
add it to the code. |
15 |
The body of the main method
has: System.out.println("Hello World");
|
Show ("Hello World"); typed,
so resulting code is: public static void main(String[] args) {
System.out.println("Hello World");
}
|