Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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 Toolsh1. >Plugins. You can also check that the Base IDE already has the Subversion Support Installed. You just need a Subversion Client.Working on OpenMRS in Netbeansh1. 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 and lastly it does not give you fine control over what you want to work with.Getting the OpenMRS Source Codeh1. 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>Subversionh1. >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.

!SVN-Folders.jpg!Steps to work on OpenMRS using Netbeansh1. h2. Create New Project

  • Once you have the source code, you want to create a new project. File>New Project (Ctrl+Shift+N)... and then Webh1. >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.

After you have set the sources classpath, you just have to click next on the Project Output. Click Finish on the web sources classpath which already has the Java Sources Classpath. After you click the Finish, a Netbeans project is created and a folder named nbproject is added the checked out source.

REMEMBER: Do not upload/commit the nbproject folder into the SVN, since other IDEs do not use this folder. Only Netbeans uses the xml files from this folder.

After you have finished creating the project, you may see some red colored error icons on your project. This happens if you did not add all the libraries to all the src folders. To solve this, like mentioned earlier, we have to edit the project.xml file located inside the nbproject folder. Open this file in your favorite text editor like notepad or kwrite or vi.

<compilation-unit>
                <package-root>src/api</package-root>
                <classpath mode="compile">lib/ant-contrib/ant-contrib-1.0b2.jar;lib/antlr/antlr_2.7.6.jar;lib/asm/asm-attrs.jar;lib/asm/asm.jar;lib/benerator/databene-commons-0.4.5.jar;lib/benerator/databene-webdecs-0.4.5.jar;lib/benerator/databene-benerator-0.5.5.jar;lib/c3p0/c3p0-0.9.1.jar;lib/cglib/cglib-2.1_3.jar;lib/commons-beanutils/commons-beanutils-1.7.0.jar;lib/commons-beanutils/commons-beanutils-bean-collections-1.7.0.jar;lib/commons-beanutils/commons-beanutils-core-1.7.0.jar;lib/commons-collections/commons-collections-3.1.jar;lib/commons-collections/commons-collections-testframework-3.1.jar;lib/commons-dbcp/commons-dbcp-1.2.1.jar;lib/commons-digester/commons-digester.jar;lib/commons-fileupload/commons-fileupload-1.1.1.jar;lib/commons-io/commons-io-1.4.jar;lib/commons-lang/commons-lang-2.4.jar;lib/commons-logging/commons-logging-1.1.1.jar;lib/commons-pool/commons-pool-1.2.jar;lib/dom4j/dom4j-1.6.1.jar;lib/dwr/dwr-205.jar;lib/ehcache/ehcache-1.2.4.jar;lib/hibernate/hibernate325-mod.jar;lib/hl7api/hapi-0.5.jar;lib/jakarta-log4j/log4j-1.2.15.jar;lib/jakarta-taglibs/taglibs-page-1.1.jar;lib/jakarta-taglibs/taglibs-request-1.1.jar;lib/jakarta-taglibs/taglibs-response-1.1.jar;lib/jakarta-taglibs/taglibs-standard-1.1.jar;lib/jfreechart/jcommon-1.0.15.jar;lib/jfreechart/jfreechart-1.0.12.jar;lib/jstl/jstl-1.1.jar;lib/jta/jta.jar;lib/junit/dbunit-2.2.jar;lib/junit/hsqldb.jar;lib/junit/junit-4.4.jar;lib/junit/xmlunit-1.2.jar;lib/mail/activation.jar;lib/mail/mail.jar;lib/mysql-connector-java/mysql-connector-java-5.1.7-bin.jar;lib/neal-reporting/Acme.jar;lib/neal-reporting/itext-1.3.jar;lib/neal-reporting/reports.jar;lib/poi/poi-3.1.jar;lib/quartz/quartz-1.5.1.jar;lib/saxon/saxon8-dom.jar;lib/saxon/saxon8.jar;lib/simple/simple-xml-1.6.1-mod.jar;lib/spring-framework/spring-2.5.1.jar;lib/spring-framework/spring-test.jar;lib/spring-framework/spring-webmvc.jar;lib/stax/stax-1.2.0.jar;lib/stax/stax-api-1.0.1.jar;lib/tomcat/catalina-ant.jar;lib/tomcat/catalina.jar;lib/tomcat/jsp-api.jar;lib/tomcat/naming-resources.jar;lib/tomcat/servlet-api.jar;lib/tomcat/tools.jar;lib/velocity/velocity-1.6-beta1.jar;lib/xerces/resolver.jar;lib/xerces/xercesImpl.jar;lib/xerces/xercesSamples.jar;lib/xerces/xml-apis.jar;lib/xstream/xstream-1.3.jar</classpath>
                <source-level>1.5</source-level>
</compilation-unit>

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

  • No labels