1. Create a directory called projects.
2. Inside this directory create a subdirectory called lab1.
3. Open a new document using a text editor.
4. Paste in the following code:
/**
My first Java program
*/
public class Greeter {
public static void main(String[] args)
{
String planet = "Mars"; //
declare a variable
System.out.println("Hello,
" + planet + '!');
planet = "Uranus"; //
update variable
System.out.println("Hello,
" + planet + '!');
}
}
5. Save this file in lab1 directory as Greeter.java.
6. Open a command shell and change the working directory to lab1.
7. Type the command:
javac Greeter.java
8. What file has been added to lab1? What happens if you try to open this file using your text editor?
9. Type the command:
java Greeter
10. What did you see? If there are problems, be sure . is on your classpath variable and the java bin directory is on your path variable.
11. Modify Greeter.java so that it greets every planet in the solar system.
12. Be able to explain every line in the program.