Netbeans 6.9.1 Notes (2011-02-08) [Note: Netbeans is a Sun-Oracle IDE (integrated development environment) open source product almost 10 years old by now (2011). These are all free downloads. The latest release is 6.9.1 which is pretty solid. This is the version I recommend because it works well for Java and other languages (C, C++, Ruby, Python). There is a newer Beta version, but not the right plugins are available for this version yet and it requires Java 7.0 early access. So, stick with 6.9.1. (There is a whole lot more to NB then my notes suggest, so an instructor will need to elaborate as they learn more). These notes cover the following configuration for the Java/NB suite. 1. Setting up Java, and Java class file documentation, 2. Setting up Netbeans, 3. Installing XML and UML plugins to NB 4. Netbeans productivity hints. 1. Editing the template Java class file(s) to edit in boiler plate code, such as automatic file name, user name, date, and Javadoc @ tags 2. Set up code macros so that typing a mnemonic will be expanded to desired code. That is, I have set mine up so that typing the 4 characters sout and hitting space bar results in System.out.println( ); with the cursor between the quote marks. (Students are really annoyed if I don t show them this option early on)!! 5. Extending NB with additional Plugins beyond XML and UML The basic NB framework can be augmented with plugins. Among the hundred and sixty or so available, I use the XML plugin and the UML plugin, plus a few others. The XML plugin allows XML editing, DTD/XML-Schema editing, and document validation, as well as XSLT editing and transformations. I have used these features in both XML (IT 408) and Java classes (IT 307, IT 407, CST 100, 200) for several years now and they work. The UML plugin allows diagrammatic round-trip engineering. Very cool, and very essential for modern software development. (For a Windows box, there are Mac version available too) Copy from instructor supplied flash drive to your hard drive:, (don t install from the flash drive!) Or, you can download all of this software from the java.sun.com site as well as mozilla.org. The java.sun.com, netbeans.org, mozilla.org sites have these downloads 1. jdk1.6 update 23(or later) -- This is the SE (standard edition) desktop software distribution. jdk means Java Development Kit. JRE means Java Runtime Environment which allows Java code to run but no development tools. 2. jdk 1.6 docs ( jdk-6u23-docs.zip this is a zip file that can remain zipped. Download from the same java.sun.com site). This contains all the Java class file Javadocs I will show you how to include this in your netbeans distribution later in these notes) C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 1
3. Netbeans 6.9.1 (get the most comprehensive version as it includes the application server glassfish). If you download yourself, be sure to get this most comprehensive version. Don t get the combination distributions, do them as I indicate here. 4. Firefox browser distribution from Mozilla.org O.K, next---: 1) First, install jdk 1.6, update 2x since Netbeans requires a Java distribution (not the JRE, but rather the JDK), take the defaults, this should place the distribution within the Program Files folder (some windows OS require it be installed elsewhere, check on this). 2) Next, install Netbeans 6.9.1, you can customize this product to take less memory and time since we won t be using Ruby, Groovy, C++, JavaFX, or Java ME If you want to add UML and / or XML-Schema capabilities, see the plugin installation instructions below: Setting up the UML and XML Modules in Netbeans 6.9.1 (2011-02-08) Follow the instructions below and the module will be automatically be downloaded for you as a consequence of the plugin update process. Steps to install the UML module ( assuming you have installed NB 6.9.1 ) Go to Tools>Plugins>Settings> add dialog In the add dialog box, give this site a name like UMLModule and type in the following URL http://ea.ddns.com.br:8090/netbeans6.8/uml/catalog.xml click OK, and NB should immediately start to search and then download plugins from this site. Now check Available Plugins( ), you should see one more plugin in the available plugins. Scroll down to find and install the uml plugin. Activating Your Module You might need to make your uml module active, so you should check it s setting as shown below: (Notice the Show Details box is checked so you can see the individual statuses as below). Check C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 2
the box and an option to activate or deactivate will be presented to you.. XML and XML-Schema Setup To add in XML-Schema editing support you will need to add in another plugin. As in the UML plugin instructions above, you will need to add another URL site to download the plugin. The plugin name is -- XML Schema and WSDL. For NB 6.9, the URL suggested is: http://dlc.sun.com.edgesuite.net/netbeans/updates/6.9/uc/m1/dev/catalog.com.gz Installing the Java API docs so that NB can display Java class documentation Given that you have NB 6.9.1 up and running, you can set up to access the Java api for all Java classes by doing the following: 1. Copy the Java Doc zip file to the Java distribution folder. In my case, the distribution folder is jdk1.6.0_21. Notice that I simply copy jdk-6u23-docs.zip into that top folder, don t unzip it. C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 3
Now tell NB where to find the Java API docs. Go to: Tools>Java Platforms >javadoc tab In the Java Platforms window, click on the Add Zip/Folder tab and navigate to your jdk-6u23-docs.zip file. C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 4
From now on, when you are in a Java source code program, and you see a Java class of interest, just right-click on the class name and a browser window will open showing the Javadocs for that class. For example, here is some source code and I right clicked on the Java class System and invoked the Show Javadoc command. And here is a fragment of the Javadoc displayed in the browser window: C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 5
Learn to create projects File>New Project> java.java application Learn to create projects then type in a name of your choice for the project. Over-type the default package name and Main class. type 'finish' Go to main menu and Run>Run Main Project just to see that it runs, with no output. Code in a System.out.println("Hello World") inside of your main method ( see handout) and run again... 4. Learn to use the javadoc tags. I will expect EVERY program from next week onward to have javadoc comments as a matter of course. The extent of the comments will emerge as we learn more. 5. When you ask for a new file, as when you right click on the package name, New>Java Class> type in a name of your choice > 'finish' what you see is the template for that file type. C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 6
Learn to create projects 5.5 To edit that template to say what you want it to say next time you create a new Java Class file, do the following: Tools>Templates>java folder> Java Class >Open in Editor ( use the file below as a model of what to edit ) 5.7 To create the doc-files folder that will hold your graphics, right click the package name > New>Other>Other>Folder (You need a Folder and it is usually included in the 'Other' miscellaneous file types) Name it 'docfiles' and copy your graphics into it.. 6. Create productivity macros tools>options> editor> code templates> type in a nickname then type in what the expanded code should look like. decide how it should be invoked ( space, tab, enter,.. ) Editing the Program File Templates The Template - Java Class File ***** An edited Java Class File. ( The Java Main Class file will be almost exactly the same except for how you want to edit the main() method. *********************************** ******Edited Java Class File ******************************************** /* ${package}.${name}, ${user}, ${date} */ <#if package?? && package!= ""> package ${package}; </#if> /**${name} shows... *<p> *<!-- uncomment start/end comment tags for graphics display * <img src="doc-files/yourgraphic.jpg" alt="graphic"/> * <a href="doc-files/yourpdfdoctxtfile.pdf" >myfile link </a> * 'doc-files' must be a sub-folder of your package folder * --> *</p> * @author ${user} * @version 1.0 ${date} * @see "" */ public class ${name} { }//end class ${name} C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 7
Literate Programming 5. When you ask for a new file, as when you right click on the package name >new>java Class what you see is the template for that file type. 5.5 To edit that template to say what you want it to say: tools>templates>java folder> Java Class >Open in Editor Create productivity macros Tools>Options> Editor> Code Templates> type in a nickname then type in what the expanded code should look like. decide how it should be invoked ( space, tab, enter,.. ) Literate Programming To improve your standing with your clients, it s always helpful to show them something extra, to delight them, to tantalize them with intimations of more to come. Part of this push comes from learning how to provide first rate documentation that is both explanatory and interesting. For our Java programs we have a built-in process to provide such documentation, Javadoc. With Javadoc, you can insert comments into your Java program that will be extracted and hypertext linked to other parts of your package or program as well as including links to other documents and graphics. Productivity Hint -- Undock Windows NB has a nice feature so that you can see multiple windows at once. Here is how I do it (2011-02- 10): 1. open up a project 2. open up all the files I might want (use either edit or open command). They will now be in tabs across the top of your editing pane 3. click on one of the files shown in the pane. 4. go to Windows>Undock Window 5. now you have an undocked window and can move it where you like. 6. If you want to see more than 2 windows, then open up another tabbed window and do the Undoc Window again 7. You should be able keep multiple windows open and by resizing them, some part will always show so that you can bring it to the front of the editing pane. 8. Submission Project Formats When you email projects to me, zip them and name them as follows: InitialsProjectNameDate(yyyymmdd).zip C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 8
Literate Programming For example, here is a zipped project that starts with my initials, the project name, and the date, in military format- yyyymmdd RRHeronFormula20110209.zip C:\acbooks\QPack2008\NetbeansNotes.fm 3/7/11 rob.r 9