Welcome: A First Java Program in Eclipse

To get Eclipse on your local machine, in D2L view Content > Miscellany > EclipseDownload

Implement and Run a Welcome Program

·  If you are in the lab and you haven’t already done so, login to your Windows account

·  Click the Eclipse Icon

·  Eclipse will start and offer a Welcome page, which you should close (if it is visible)

·  While in Eclipse, select Windows > Preferences > Expand Java > Select Compiler

·  Create a new project by clicking on File > New > Project

·  Make sure Java Project is selected, and then click the Next (at bottom)

·  Name your project with a name indicating the lab# and your name: Lab1_Chris

·  Create a class with File > New > Class

·  After Name: type the name of the class you want to create. For project 1, the first class you create will be called Welcome. After you type that in, click Finish (at bottom).

·  Type in the following code as it is shown below. As you type, you may encounter squiggly red lines under portions of your code. This is the compiler telling you that you may have an error. To be sure, type the entire line as shown below. For help, look at the messages in the Tasks view under your program (or let the mouse hover over the error).

·  Once everything is typed in, save the file by going to File > Save (or Ctrl-S for short). Saving the file compiles the code into a class file and updates the error messages. Fix any errors you may have before you go on.

·  Next, go to Run >Run As > Java Application

·  At the bottom of the screen in the Console box, you should see some output that says

Welcome. What is your name?

·  Click on the console window to the right of this prompt

·  Type in your name (input is green like Jane) and press the enter key

·  The dialog should look like this (with a different name unless your name is Jane):

Welcome. What is your name? Jane

Hello Jane! I hope you are well :-)

Print this File for your Turnin

·  Make sure your name is in the comment at the top of the file.

·  From Eclipse, select File > Print

·  If you are in a CS lab (228 or 930 Gould Simpson), locate the nearest printer name and select that printer from the list of printer names in the dialog.