DOC PREVIEW
UGA CSCI 1301 - Lab2

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSCI 1301 Lab 2 - NetBeans Basics The purpose of this lab exercise is to become familiar with NetBeans, an Integrated Development Environment (IDE) that will assist you to develop your java programs. In this lab assignment, you will create, compile and execute a simple java program called HelloWorld.java in the NetBeans environment. 1. Before you start becoming familiar with NetBeans, create a folder on the desktop called CSCI 1301. Then click on Start/All Programs/NetBeans/NetBeans 6.1 You should now see this window.2. In NetBeans, a project is a collection of one or more java source code files with an extension .java. Let’s learn how to create a simple java project having only one java source file. Click on New Project in the File. The following window will be displayed:3. In the New Java Application window of the wizard, do the following (as shown in the figure below): • In the Project Name field, type HelloWorldApp • Select the folder CSCI 1301 you just created in Step 1 to save your first CSCI 1301 project. Use the Browse button at the right of the Project Location to locate such a folder. • In the Create Main Class field, type helloworldapp.HelloWorld • Leave the Set as Main Project checkbox selected 4. Click on the “Finish” button. When you instruct NetBeans to create a new project, it creates a folder with the name of your project in the Project Location you specified. In this example, NetBeans creates the folder HelloWorldApp in the folder CSCI 1301. In this folder, NetBeans also creates a folder called src that contains another folder named with the project’s name in which all the java source files of your project will be located. Afterwards, you will see a window like this:The Source editor window appears in the right window. You can enter and modify you java source code using the source code editor. As you can observe, NetBeans had automatically generated a template of the class HelloWorld and included a template of the main method within the class. The code of the new class is then displayed in the Source editor window. NetBeans source editor offers some helpful features that help you to enter and read java source code in an easy manner. For example, • Tabs are used to indent several parts of the program. This makes your code more readable and easier debug. • Words in blue are keywords in Java, words that belong to the Java’s vocabulary. We will learn the specific function of this word throughout the course. • Lines in grey are comments that provide documentation to your program but are not part of the java code meaning that comments will not be executed by the Java VM. • Braces and parenthesis comes in pairs. If you place the cursor on either side of some of the braces (and parentheses), NetBeans will underline its corresponding partner. This feature is useful when you need to find mismatched or unmatched braces or parenthesis in your code, which are common sources of syntax errors.5. Click on the editor window. In the main method add the line System.out.println("Hello World!"); After the comment line (in grey ): / TODO code application logic here Afterwards the HelloWorld.java window should look like this: • Notice that the phrase “Hello World!” is in orange, which means it is a String literal. A String literal in java is a sequence of characters enclosed between double quotes. In this example, the String literal is used to display a greeting message to the user.6. In the Build menu, choose “Build Project”. This will run the javac compiler against all of the source code you have associated with this project At this point, the Output window opens and displays output similar to this: If the compilation step is successful, you will see the statement BUILD SUCCESSFUL at the bottom of the output window. If the compiler finds syntax errors in your program, the message BUILD FAILED will be displayed as well as a list of all the syntax errors found. Syntax errors are reported as a hypertext link, clicking on an error hyperlink will navigate to the source of the error in your code. After you locate the error, you must fix and build the project again until program is successfully compiled. If your source code has no syntax errors, the java bytecode file HelloWorld.class is generated in the folder build/classes/helloworld in the HelloWorldApp folder. You can see where the new file HelloWorld.class is generated by clicking on the build/classes/helloworld folder in the Files tab. 7. To run your first java program, click on Run Main Project in the Run menu. The output window will display something like this: Note that the message Hello World! is displayed in the Output Window.8. Click on the Files tab on the left to see a folder-based view of your project, including files and folders. Expand the folders build and src until you see something like this: . 9. Before you exit NetBeans, click Close “HelloWorldApp”on the File menu. If NetBeans prompts you to save the modifications, click on Save All. Finally, click on Exit in the File menu. 10. Finally, you should submit the file HelloWorld.java in WebCT to get credit for this lab exercise. To do so: • Login into WebCT and click on the Project Assignments link in the Course Menu or click on Course Content/Project Assignments. • Click on the Lab Assignment 2 link. • Click on the Upload file button. • Click on the Browse button that appears in the Upload File for Lab Assignment 2 window. • Click on the file you want to upload and afterwards click on Open. • Click on the Upload button and locate the HelloWorld.java you have created in the previous steps. The file HelloWorld.java should be in the folder HelloWordApp/src/helloword in the CSCI1301 folder you have created in your computer. • Type your e-mail address under Notification to receive an e-mail confirming your assignment has been submitted.• Click on the Submit Assignment button. An assignment confirmation page will be displayed just after you submit your file. Important: Remember, you must upload the file you want to submit and then click the Submit button. Otherwise, if you upload your file(s), but forget to click on the Submit Assignment button, the file(s) have not been submitted to be graded. • If you want to check the submission status of your lab assignment, click on Project and Lab Assignments. The submission status of a project assignment is shown under the project's


View Full Document

UGA CSCI 1301 - Lab2

Documents in this Course
Load more
Download Lab2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?