Hello World


Compiling, Variables

VariableExample.java

Deitel Chapter 2


Classwork

Part A - Hello World

Open NetBeans and create a new project,  making sure you do the following

Once you are editing MyHello.java, at the top add a comment with all group member names (whenever you see an instruction like this while working independently, make up an imaginary second person's information to use).  Remember comments start with //

 	// this is a comment

Inside your main (that is, between the curly braces of the main method)  paste the following code:

        System.out.println("Hello World");
Run the program  using Run>Run File or Shift+F6.   You should see Hello World printed out in the output below. (You should not need to explicitly compile first, NetBeans recompiles constantly).

Part B - working with NetBeans

 Changing the name of the project: Right click on the project name in the tree at the left and use Rename change the name of the project using today's classwork number and your user name or group number (cwk01gjsmith, cwk00g02, whatever).  Make sure to click the Also rename project folder checkbox!!

Changing the name of a file: Right click on the MyHello file in the tree at the left and use Refactor>Rename to change the name of the file to HelloWorld. 

Note that this changes the class name in the file as well -- the class name must match the name of the file.

(Note: Because of the way Windows works, if you try to make a change that only affects capitalization, the file system gets confused.  So if you accidentally called it myhello, you'd have to change to some other name and then back e.g. myhello > tempname > MyHello)

Adding new classes, and adding example code to your project.  Right click on the package (yellow icon, just above the HelloWorld.java file) in the tree at the left and add a new Java class named SaysHello. Go into this example code link:  SaysHello.java and copy all the text.  Replace the text of the new file you just created in the IDE. 

There is now an error at the top, because my package name is different from yours.  Netbeans puts a lightbulb in the margin of the code to show you where the problem is.  Click on the lightbulb and you should see an option to change the package declaration; clicking on it should fix the problem (you can also fix this simply by typing the correct name in the package statement.)

Both HelloWorld and SaysHello have main methods, so both can run.  To run the file you are looking at, make sure you use Run File, not just Run.  Run SaysHello, which gives examples of creating variables, doing operations, and printing.


Part C - Turning In

Go to where your project directory was saved by NetBeans.  Right-click the folder icon and click Send To> Compressed (zipped) folder.  A .zip file should be created. 

 In Blackboard, under Classwork, you will find an entry for this classwork (group links have a picture of people, assignment links have a picture of drawing tools).  Click it. (If you ever see a blue Continue button at the right, click it and you should then see the submission page.)

Attach your zip file and submit.  Looking at your submitted assignment, you should see a link to download your project zip file. 

Click the link for your project and download it to your computer, then unzip it. Drag the unzipped directory to the editing area of Netbeans. Your project should open (this will probably mean you now have two copies of your project open).

Using this process you can always go back and get a copy of the work you submitted.    It is your responsibility to check that you have turned in the correct project, correctly zipped, so I would strongly suggest downloading and checking your work every time you submit.