DOC PREVIEW
FIU COP 2210 - Using the NetBeans IDE

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 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 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Using the NetBeans IDEI. OverviewX. Capturing the Program Output – Copy and PasteComputer Programming I and II Instructor: Greg ShawCOP 2210 and 3337 Using the NetBeans IDEI. OverviewNetBeans is a very powerful, professional-grade program, with many advanced features.However, it is easy to master the basics.- Every Java program consists of one or more Java classes- A Java class is stored as a Java file, with extension .java- A NetBeans project is a folder in which we store all the Java files that make up aprogram- Generally, programmers create a separate NetBeans project for each program, andyou should do so for each programming assignment. However, for the labs(Programming I only!) it will suffice to create a single project to store all of your labprograms. This will save time during the lab sessionsII. Creating a Project 1. First, create a folder that will contain your project (or projects). Let’s call it MyProjects(You only need to do this once, and then store all your projects in this folder)2. Start NetBeans3. From the File menu, choose New Project (The New Project dialog box will open)4. In the New Project dialog, under Categories choose Java and then under Projectschoose Java Application, and click Next. (The New Java Application dialog box willopen)5. In the New Java Application dialog, in the Project Name text box, enter a name for theproject (e.g, 2210). To the right of the Project Location text box, click the Browse buttonand navigate to your MyProjects folder (from step 1). Click Open. The Project Foldertext box will now display the path to your project folder (2210) which will be in yourMyProjects folder.IMPORTANT: Make sure you remove the check from the Create Main Classcheckbox and then click FinishIII. Creating a Java Class (.java file) with a main Method1. From the File menu, choose New File... (or just click the New File button on the toolbar)2. In the New File dialog, under Categories, choose Java. Under File Types, choose JavaMain Class. Click Next.3. In the New Java Main Class dialog, enter a name for your class and click Finish4. A template for your class will appear in the Editor window and an icon with the classname will appear in the src folder in the Files window  If the Files window is not visible, open it via the Window menu5. In the comment block above the class declaration, enter your name as the author (ifnecessary). E.g. @author BubbaYou can delete the other 2 comment blocks6. Enter the code for your main method in place of the TODO commentIV. Creating a Java Class without a main Method1. From the File menu, choose New File... (or just click the New File button on the toolbar)2. In the New File dialog, under Categories, choose Java. Under File Types, choose JavaClass (not Java Main Class) and click Next.3. In the New Java Class dialog, enter a name for your class and click Finish4. A template for your class will appear in the Editor window and an icon with the classname will appear in the src folder in the Files window. 5. Enter your name as the author and delete the comment block in lines 1-4.6. Enter the instance variable declarations and methods of your class inside the braces { }V. Opening a Saved ProjectFrom the File menu, choose Open Project…VI. Closing an Open ProjectFrom the File menu, choose Close Project (name)VII. Compiling and Executing a Project1. Open the project2. Make your main class (the one with the main method) the “active” class by double-clicking the file name in the src folder in the Files window, or by clicking the tab above theEditor window (aka: the “code” window)(If the Files window is not visible, use the Windows menu to display it)3. Right-click in the Editor window and choose Run File from the popup menu (or press[Shift] + F6). This will compile all the classes of the program and – if there are no syntaxerrors – execute it4. If there are no syntax errors, the program output will appear in the Output window at thebottom of the screen, after the message “BUILD SUCCESSFUL”. Otherwise, a list of theerrors will appear and you will have to fix themVIII. Correcting Syntax Errors1. Read each error message calmly, carefully, and thoroughly. There is an art tounderstanding the messages and fixing the errors, and you will greatly improve with time2. Each error message also includes a link to the erroneous code. Click the link and edit thecode You may prefer to correct the syntax errors using the Task window - which listseach more succinctly – rather than in the Output window(If the Task window is not visible, use the Windows menu to make it so)3. Continue correcting the syntax errors and re-compiling until the output and the message“BUILD SUCCESSFUL” appears, indicating no syntax errors Tip: Scroll up in the Output window (or Task window) and correct the errors in theorder they appear. Often, correcting an error near the beginning of a file will correctseveral subsequent errorsIX. Printing Your Java Files (aka: Your "Source" Code)Choose Print... from the File menu to print the active file (i.e., the one displayed in the Editorwindow)X. Capturing the Program Output – Copy and Paste1. In the Output window, drag to select the output2. Right-click the selection and choose Copy from the popup menu 3. In NetBeans, create a new, empty file (From the File menu, choose New File..., categoryOther, and file type Empty File)4. Right-click in the Editor window and choose Paste from the popup menuXI. Saving Your Java FilesFiles are automatically saved when they are compiled. If you close NetBeans (or the project)and one or more files have been modified and not saved, you will be prompted to save them.You can also use the Save, Save As, and Save All commands from the File menuXII. Adding Existing Classes to a ProjectTo add a pre-existing .java file to your project (e.g. a file you created in a different IDE or in adifferent NetBeans project or downloaded from the class website)1. Use Windows Explorer (not Internet Explorer) to copy the file and paste it into the srcfolder in your project folder, or 2. Create a new file in your project and copy/paste the existing code into it It is never necessary to do this for classes from the Java “API” (library)XIII. Compiling Individual ClassesClasses may be compiled individually without running the


View Full Document
Download Using the NetBeans IDE
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 Using the NetBeans IDE 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 Using the NetBeans IDE 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?