Previous Next

Using NetBeans IDE for Development

You can use NetBeans IDE for Java/PHP/Ruby development. NetBeans IDE supports integrated configuration windows for managing web servers and databases directly from the IDE. Note that the version of NetBeans available in the official pkg repository may be of an older version than the one available through the NetBeans web site. The following sections shows you how you can configure NetBeans IDE 6.0 for your development needs.

Setting Up Server Environment

What good is an IDE without integrated server/runtime support for web development? The NetBeans IDE supports various Java EE servers and other web servers for application deployment. You can have multiple servers configured in NetBeans irrespective of the server that will be used in your projects. Thus you can have Apache 2 Web Server configured for deploying PHP files, Apache Tomcat container configured for deploying Java based web applications or a WEBrick server for deploying Rails applications.

Apache Web Server

To configure Apache Web Server in NetBeans IDE, perform the following tasks:

To Configure Apache Web Server in NetBeans IDE
  1. In NetBeans IDE, go to Services Tab.
  2. Expand Web Servers node.
  3. Right Click on Web Servers node and click Add Web Server.
  4. Choose Server Type - Add a connection name. For example, Apache 2. Select Local Web Server with File Access option so that you can instruct NetBeans to use Apache 2 server installed through Web Stack.
  5. Find Configured Hosts - Select Auto Configuration. Servers. Click Find Servers. The Server Location field is automatically populated.
  6. Configure HTTP Server - Enter Server Name as localhost.
  7. Configure File Access - Enter Document Root as /var/apache2/2.2/htdocs (If not auto selected).

    After adding the server, check if Apache Web Server shows up the Web Servers list by clicking Services tab.

    These are the basic steps to get you started with using Apache web server for deploying your PHP based web applications. Since Apache Web Server is already configured to support PHP files, you do not need to perform any other configuration apart from getting and installing the PHP plug-in.


    Caution - The procedure mentioned above is applicable only for NetBeans IDE 6.0, which is available through the pkg repository. If you are using NetBeans IDE 6.1, you don't need to configure web servers up front. You can configure a server, while creating projects.


Tomcat Web Server

Web Stack comes with Tomcat 6.0 Servlet container for deploying your JSP based web applications. Some of the examples shown later in this document uses Tomcat in NetBeans. The NetBeans software for this release may not come bundled with the Tomcat server as Tomcat is already available in Solaris through Web Stack. But still you need to let NetBeans know where your Tomcat installation directory is to allow NetBeans manage Tomcat.

To Configure Tomcat Web Server in NetBeans IDE
  1. In NetBeans IDE, go to Tools > Servers.
  2. In the left pane, click Add Server.
  3. Choose Tomcat 6.0 from the servers list.
  4. In the Catalina Home field, type /opt/apache-tomcat-6.0.14 (Make sure that path exists).
  5. Add the user name and password for the manager role as provided in tomcat-users.xml file in the Tomcat configuration directory. You can also let NetBeans create a new user if the user entered in the user name text field does not exist.

    When Tomcat is successfully configured in NetBeans, the Servers node shows Tomcat 6.0 entry.

    You can right click on the Tomcat 6.0 node and select Start to start the server.

WEBrick Server

NetBeans IDE 6.0 comes bundled with WEBrick, the most widely used Ruby web server. WEBrick is started automatically on Rails project creation. There is a WEBrick console window that shows the output of the web server. No other manual configuration is required for the WEBrick server. For using Mongrel or any other server, update your gems by invoking Tools > Ruby gems.

Languages and Application Support

There is a widespread misconception that NetBeans is an IDE for Java development. In fact NetBeans IDE supports working with non-Java scripting languages like PHP, Ruby, and other such scripting languages. If you are using NetBeans IDE 6.0 in Solaris OS, you can work with any of these scripting languages supported by Web Stack.


Note - Visit http://scripting.netbeans.org for more information on scripting support in NetBeans IDE 6.0.


For Java Development

Use NetBeans IDE for Java based development including web, enterprise, and mobile development. Please refer to http://java.netbeans.orgfor on overview of supported features.

For PHP Development

PHP is an interpreted, dynamic, web page scripting language. NetBeans IDE 6.0 has support for PHP editing and debugging through an add-on component called PHP plug-in. The plug-in supports PHP5 and the following features:

  • Formatting, folding, and bracket completion of the PHP code.

  • Syntax highlighting.

  • Combination of HTML and PHP blocks.

  • Code completion.

  • Debugging.

  • Automatic detection of configured servers.


Note - Supported Version – PHP 5.2.4


When you have downloaded and configured the plug-in, you should be able to create new PHP projects. However to run and debug your PHP projects, you will need:

  • Apache 2 - Available through Web Stack. You can use a local server or a remote server with FTP access. Typically a local web server is utilized for development and debugging, while the production environment is located on a remote web server.

  • PHP engine - Available through Web Stack.

  • PHP debugger - Available through Web Stack PHP Extension. The NetBeans 6.0 IDE PHP Plug-in allows you to use XDebug, but using a debugger is optional.

For using PHP and Apache 2 through Web Stack, you do not need any additional configuration.


Note - PHP language interpreter is integrated into the Apache Web Server. PHP module with MySQL and PostgreSQL database support is provided for Apache Web Server. If you need to configure PHP with Apache 2.2 worker MPM, then you need to use Apache 2.2 Web Server + PHP FastCGI.


Some PHP modules are packaged with Web Stack package as extensions. Each of the modules has a respective INI file under /etc/php5/5.2.4/conf.d directory. These PHP extensions are enabled by default. Some custom third-party PHP extensions are not enabled by default. However, you can edit the PHP extension specific INI file for any specific configuration changes.

For enabling debugging support in PHP, perform the following steps:

  1. Click Applications > Developer Tools > Web Stack Admin > Options.

  2. Go to PHP tab and click ‘PHP Debugger’ check box.

In the PHP tab, click Advanced Configuration to open the INI file for editing. To enable PHP debugger extension, edit the file /etc/php5/5.2.4/conf.d/xdebug.ini

Available PHP Extensions

If you have installed the amp-dev package, some PHP modules are available as extensions. Each of the modules has a respective INI file under /etc/php5/5.2.4/conf.d directory. These PHP extensions are enabled by default. Some custom third-party PHP extensions are not enabled by default. However, you can edit the PHP extension specific INI file for any specific configuration changes. For a list of supported PHP extensions, refer to the Web Stack Getting Started Guide.

DTrace Support

DTrace support is available for Apache Web Server, PHP, and MySQL. After starting Apache Web Server execute the following command as root user:

dtrace -l | grep php

You will see a list of DTrace probes. Get the SUNWDTraceToolkit package to try out some D Scripts.

For Ruby/Rails Development

NetBeans features plug-ins that provides an integrated development environment for building, running, testing, and debugging Ruby and Ruby on Rails applications. NetBeans supports Ruby project types including Ruby files, RSpec specification files, and YAML files. You can configure NetBeans to use the native ruby available through Web Stack. The IDE also supports Rake build tool integration and gives you access to the Interactive Ruby Shell.


Note - If you need to use the Gem Manager, you must have gem installed, and the IDE must have write permission to your Ruby installation directory.


/var/ruby/1.8/gem_home contains the Ruby gems repository. Configure the GEM_HOME environment variable to point to /var/ruby/1.8/gem_home to use this installation of Ruby gems. /usr/ruby/1.8/bin contains the Ruby executable as well as other utility programs. These programs are linked from /usr/bin. For example, /usr/ruby/1.8/bin/ruby is linked from /usr/bin/ruby1.8, and may be linked from /usr/bin/ruby if 1.8 is the latest version of Ruby installed on this system.

Before proceeding to use NetBeans for Ruby, you need to set the environmental variable GEM_HOME.

For sh -> export GEM_HOME=/var/ruby/1.8/gem_home
For csh -> setenv GEM_HOME /var/ruby/1.8/gem_home

Caution - For using gem, make sure you have direct access to Internet. If your system is behind a firewall or if it uses a proxy server, set the HTTP_PROXY variable.


If you do not set the GEM_HOME environmental variable, NetBeans IDE will not work as the available gems cannot be enumerated if you are using a native Ruby environment. For this reason you need to set GEM_HOME for the gem repository to be accessible from the NetBeans IDE. Also the directory referenced by GEM_HOME should be writable. So make sure you execute the following command:

$ chmod -R a+w/var/ruby/1.8/gem_home
Ruby on Rails (RoR)

Rails is a full-stack framework for developing database-backed web applications. Rails provide a pure-Ruby development environment. Ruby gems is the standard Ruby package manager. If you have successfully installed the ruby-dev package, ruby gems are already loaded. Hence you can install Rails and its dependencies by executing the following command:

/usr/bin/gem install rails --include-dependencies

You can also install rails directly from NetBeans IDE rather than invoking the gem command through command line. The Ruby on Rails environment is set up for the development. You can now use NetBeans IDE to create a Ruby on Rails project. When you create a project, the IDE creates the same folders and files that a rails command would create.

Ruby Gems

Ruby Gems is a system for managing Ruby software libraries. Ruby code packaged in this manner is called a gem. Gems allow downloading, installing, and managing your Ruby libraries. Web Stack bundle in Solaris does not include a lot of bundled gems as you can use Ruby Gems to download and install additional gems. You can use the NetBeans interface for managing Gems.

For more information on configuring Ruby Gems, refer to the documents at http://ruby.netbeans.org/.

Previous Next