USING ECLIPSE TO CREATE HELLO WORLD
Steps Create a Java project Define the build settings Add a class to the project Complete the code for the main procedure to write to the standard output device
Eclipse Default Workspace When you start Eclipse, you must first select a workspace The folder where your programs get stored I suggest that you use a USB stick for all programs so put the default workspace there That way you can access programs from any computer The default workspace really nothing more than a folder where applications are stored
Eclipse Workspace (Example) Select or create a default workspace
Creating a Java Project
Defining the Build Settings
Add a Class to the Project Click File, New, Class to begin creating the first class
Create the code
Dissecting Hello World (1) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } public is an access modifier
Dissecting Hello World (2) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } Everything is a class
Dissecting Hello World (3) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } The case sensitive class name is FirstSample
Dissecting Hello World (4) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } Braces enclose all blocks including a class block
Dissecting Hello World (5) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } Braces enclose all blocks including a procedure block
Dissecting Hello World (6) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } The entry point is public
Dissecting Hello World (7) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } static means the method is shared. It’s true for all program entry points!
Dissecting Hello World (8) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } void means the method does not return a value. It’s the same as a Sub procedure in VB
Dissecting Hello World (9) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } main is always the name of the entry point
Dissecting Hello World (10) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } The method argument list (type varname)
Dissecting Hello World (11) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } Brackets mark array arguments (like () in VB). The data type of the array is String
Dissecting Hello World (12) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } We don’t use it but it’s the argument variable
Dissecting Hello World (13) public class FirstSample { public static void main(String[] args) System.out.println("Z. Beeblebrox"); } And finally the method call to print a message to the Console View