Hello World


Compiling, Variables

VariableExample.java

Deitel Chapter 2


Classwork

Part A - Hello World

Open NetBeans and create a new project,  Set the project name to temp (so that we can rename it later)

Once you are editing the automatically created java file, 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("Programming I in Java: Hello, world!");
Run the program  using Run>Run File or Shift+F6.   You should see the message 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 to 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 .java 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 helloworld, you'd have to change to some other name and then back e.g. helloworld > tempname > HelloWorld)

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 BrightSpace, at the top, under Course Tools click Groups. Find the list of groups for this classwork and join the one with your number or the number you have agreed on in your group. Then, under Course tools click Assignments and find the entry for this classwork. Click Add File and then Upload, Then My Computer and browse to find your zipped project directory (if you didn't already, you can just right-click zip your project directory right now, then click the resulting zip). Click Add then Submit.

If you go back to this assignment again, 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.