Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Table of Contents
outlinetrue
indent20px
stylenone
printablefalse

Introduction

Netbeans is a free, community developed opensource IDE which can be used for programming in a host of languages like Java, C/C++, Ruby, Python. Most developers from the OpenMRS community work on Eclipse IDE, but open-source means you have the choice to use your own tools and this How-To Guide is directed to developers who want to develop OpenMRS using Netbeans IDE.

Tools Required

  1. Netbeans IDE with Web & Java EE Bundle (Tutorial uses v6.1)
  2. SVN client (optional, but recommended for easy checkout and commit of code)
  3. Hibernate Support plugin (optional)
  4. Spring Framework Integration (optional)
    The above plugins can be installed from the Plugins Manager found under Tool->Plugins. You can also check that the Base IDE already has the Subversion Support Installed. You just need a Subversion Client.

Steps to work on OpenMRS 1.7 and older (non-mavenized codebase of OpenMRS) using Netbeans

You can starting working with OpenMRS in Netbeans in 2 different ways. You can create a new project with existing source code or you can use the Eclipse Project Importer plugin for Netbeans. The use of Eclipse Project Importer is NOT recommended because firstly you need to download the plugin (isn't part of Base IDE). Secondly you need a working Eclipse workspace (created when using Eclipse) where you have opened the openmrs project. Lastly it does not give you fine control over what you want to work with.

Getting the OpenMRS Source Code

If you have installed the SVN client from the above link, then you can download the source code from OpenMRS's SVN servers. Click On: Versioning->Subversion->Checkout. This will open the Checkout window as shown below:

...

Enter the Repository URL as shown in the image for checking out the openmrs source code. For modules sources, you can use: http://svn.openmrs.org/openmrs-modules. The username & password can be left blank for anonymous checkout or you can enter your user/pass so that commit is easier.
The next screen will allow you to checkout specific folders, like trunk, branch etc. Specify a Local Folder, where you wish to store the downloaded sources.

Create New Project

  • Once you have the source code, you want to create a new project. File->New Project (Ctrl+Shift+N)... and then Web->Web Free-Form Project

Select Source Location

  • Select location of the source folder. Selecting the correct location will automatically fill the other fields in the dialog by parsing through the ant script (build.xml).

Mapping Ant Targets

  • The next screen automatically detects the various targets from the ant script. You can map the IDE functions to targets from the ant script. You can map the functions from the drop-downs like shown in the screenshot below:

Select Web Sources

  • The web sources are automatically selected or you can select as shown in the screenshot

Select Source Files

  • The source packages for OpenMRS are located inside the src\api and src\web whereas the tests are located inside test\api and test\web

Source Classpath

Selecting the Java Sources Classpath is an important step and Netbeans doesn't understand libraries automatically. Thus, each Source Package folder will need the libraries. This can be a long procedure, but editing the *project.xml file inside nbproject folder makes the process less tedious. But we will do this after the project is created. For the time being, just add the libraries to one source package from the dropdown.

...

You have to ensure that each package-root section has the classpath tag like shown above. You can copy paste the same libraries for all the package-root folders.Creating a Module in Netbeansh1. Creating a module for OpenMRS in Netbeans is exactly the same procedure. You have to checkout the module sources and then create a new project. But there is no WEB-INF folder that is required and you can keep it empty when entering it in the wizard. Also, you may want to use the ant script's package-module to be mapped with the IDE's Run operation. This will create an omod file which you can load through the OpenMRS admin page.Tomcat Changes for Working in Netbeans==
Netbeans comes with a built-in Tomcat (or Glassfish). You have to change the OpenMRS Default Properties to tomcat.port = 8084, since the built-in Tomcat uses port 8084 by default.

Using Maven in Netbeans

http://www.netbeans.org/Using Maven in Netbeans IDE