NetBeans

Installation on Linux

One effect of most of the JDK code being now available under GPLv2 is that the demand for integrated developmental environment to create Java solutions is getting a greater attention and push. NetBeans and Eclipse are two excellent open source IDEs with liberal licensing terms. (Keep in mind that being open source and having liberal license are two different things. Being open source does not guarantee liberal license.)

NetBeans is available under mixed licensing terms. Its licenses are a mix of GPLv2 with some exception and Common Development and Distribution License (CDDL). CDDL is one of the licenses that have gone through approval process of Open Source Initiative (http://www.opensource.org/licenses/category) and comply with its Open Source Definition. An executive summary about CDDL is available at http://www.sun.com/cddl/CDDL_why_details.html. CDDL allows developers to view, use, edit, and alter the code, and distribute it or use it in production. It is because NetBeans is not completely under GPL, it is not carried in Red Hat/Fedora distributions.

NetBeans installation on Red Hat based Linux distributions is very easy. Download latest version of netbeans from http://www.netbeans.org/downloads/. NetBeans Integrated Development Environment is available in various bundles. If in doubt, download the All packs bundle with size around 200MB.

Switch user (su) to root. Change directory (cd) to where netbeans is downloaded. Make the downloaded netbeans-verNo-linux.sh file executable (chmod +x *.sh), and run the file as:

# chmod +x netbeans-6.5beta-linux.sh

# ./netbeans-6.5beta-linux.sh

Fig. 1: NetBeans Packs. Tomcat server is available if you Customize

The first screen gives you an option to customize what all to install. If you are lazy or do not care, just click Next. It is also a safe option. GlassFish is the default application server but if you want to work on Tomcat server, you have to Customize and select it. The next window displays License agreement. Just accept it and click Next. You are now shown the location where netbeans IDE will be installed (by default, /usr/local/netbeans-verNo). If you like, change it to another folder (say, /opt/netbeans-verNo). Also the installer finds out the location of installed JDK and displays it (/usr/lib/jvm/java). You can point to another JDK installation, if there is one. The next window is regarding GlassFish Java Application Server installation (v2ur2). Several defaults are presented as:

Glassfish installation folder: /usr/local/glassfish-verNo

JDK for Glassfish application server: /usr/lib/jvm/java

Admin user name: admin

Admin Password: adminadmin

HTTP port: 8080

HTTPS port: 8181

Admin port: 4848

These defaults can be changed. But do not change port numbers unless the installer advises you to do so or you have reasons to change them. If, for example, another application is already listening at one of the specified ports then the port number has to be changed.

The next window (in NetBeans 6.5 Beta) pertains to specifying installation folder for Glassfish v3-prelude-b15b. Accept or change the installation folder and click Next. A summary of installation folders is presented and on clicking Install button, installation begins. The last window is regarding (optional) registration.

Adding GlassFish server

Login as any user on your Linux machine and start NetBeans as: Applications->Programming->NetBeans IDE. Click Services in the top-left window and expand Servers node (Fig. 2). Normally GlassFish server should be available. GlassFish is an open source Java Application Server. It is available under Common Development and Distribution License (CDDL).

If you have installed GlassFish separately or it does not appear under Servers node, proceed as below to add it.

Fig. 2: Services window on top-left. GlassFish server does not appear under Servers node

Right-click on the Servers node and click Add Server (Fig. 3).

Fig. 3: Right click on Servers node and in the context menu click Add Server

Choose Server window appears (Fig. 4). Select GlassFish V2 and click Next.

Fig. 4: Select GlassFish V2 and click Next

Specify the folder location where GlassFish is installed (Fig. 5) and click Next. Let the default selection of Create Personal Domain stay.

Fig. 5: GlassFish installation folder is to be specified here. Let default choice of Create Personal Domain stay. Click Next

In the Domain Folder Location (Fig. 6) window, specify a folder where domain will be created. On this folder the logged in user should have read/write permissions.

Fig. 6: Specify a folder where the logged in user has read/write permissions

GlassFish works through domains. A domain is an application server environment for an instance of server. By this is meant that there is one set of configuration parameters associated with a domain (Fig. 8). Another domain can have another set of configuration parameters. An application lives in this environment. There can be multiple server environments (domains) with multiple applications running in these and thus achieving independence.

Fig. 7: Domain admin login particulars

Each domain has it’s own web-based administration console. Through this console one can control the domain and deploy applications. For this purpose, you need to remember the Admin Username and Admin Password supplied in Fig. 7.

Fig. 8: Server ports configuration details for this domain. Note that Admin port is 4894 and not default 4848.

Note the admin port (4894) for the domain being created (Fig. 8). After the domain has been created and server started (Fig. 9), you can access the domain admin-console through http://localhost:4894 (Fig. 11).

Fig. 9: GlassFish server added

Anytime after GlassFish has been started, you will find it instructive to view server logs to debug problems in your application. For the purpose, right-click on the GlassFish under Servers node and from the context menu click View Server Log (Fig. 10). Very useful information regarding failure of your application can be gleaned from these logs.

Fig. 10: GlassFish server started. Server logs can give very useful application debugging information

Fig. 11: Admin console for GlassFish domain

Connecting MySQL server

NetBeans has variety of packs. One package of NetBeans also contains MySQL server. However, as every RedHat based Linux distribution carries MySQL server there is no point installing the package of NetBeans with MySQL server. NetBeans (or rather your Java application) will need to access the MySQL server through JDBC driver. NetBeans includes the MySQL java connector. Incidentally, rpm for mysql-connector-java is also available in Fedora repositories. Its jar files get installed under /usr/share/java.

Fig. 12: Connecting to MySQL server

To connect to MySQL server, in the Services window, right click on the MySQL (Connector) driver (Fig. 12) and in the context menu click on Connect Using.

Fig. 13: New Database Connection window

A New Database Connection window opens (Fig. 13). In this window the following information is to be supplied:

MySQL server Host IP address (say, 192.168.1.3)

Port at which this server is listening. Generally 3306

Database name to connect to (say, expt)

MySQL Server user who has necessary privileges over the database (say mahadev)

Password of MySQL user (say, mahadev)

This information is written in a URL format as below (Fig. 14). Click OK.

jdbc:mysql://192.168.1.3:3306/expt

Fig. 14: MySQL server connection information

A Connection established message will appear under Advanced tab (Fig. 15). Click OK to close the connection window.

Fig. 15: Connection established information

The particular MySQL connection will now get listed (Fig. 16). You can now develop an application that accesses this database.

Next time you start NetBeans, this connection icon (or connection badge) will be there. but a wavy white line will pass through vertically. Right click on this connection-icon and from the context menu click Connect. You will be asked to supply just the user password and connection will be established. Of course, you can elect to store this password permanently in NetBeans (see checkbox Remember Password in Fig. 14).

Fig. 16: Services window with the mysql connection listed. Note that other icons have a wavy white lines passing through

Konqueror as default browser

To change your preferred browser from Firefox to Konqueror in NetBeans, click on Tools->Options (Fig. 17).

Fig. 17: Adding default browser

Under General options group (Fig. 18), click on the Edit button to open Web Browsers window (Fig. 19). Here fill in the form as shown in the figure and click OK.

Fig. 18: Click on Edit

Fig. 19: Edit window. Fill in Name, Process file and its arguments

From now on, Konqueror will be the default browser.

Adding Java Documentation

To add latest Java documentation to NetBeans, download Java SE6 Documentation (jdk-6-doc.zip) from http://java.sun.com/javase/downloads. Now start NetBeans and click on Tools->Java Platforms (Fig. 17).

In the Java Platform Manager, click on the Javadoc tab and click on the button Add Zip/Folder (Fig. 20). In the Browse window point to the just downloaded zip file. Click Close.

Fig. 20: Add the zipped file you downloaded

Resetting Windows

As NetBeans has number of windows, it is not unusual to close a window by mistake or to disturb a window’s location. To bring the windows back to their default settings, click, Window->Reset Windows (Fig. 21).

Fig. 21: Resetting windows

*********************