ERP 2.50:Developers Guide/Installation and setup of Netbeans IDE
Important note: Netbeans is a fully functional development environment for Openbravo ERP but at the moment this document is just an skeleton and is not ready for production purposes. Eclipse is the preferred development environment for Openbravo ERP. The following page describes how to setup and configure Openbravo within Eclipse. Installation and setup of Eclipse IDE. |
Contents |
Introduction
This article is a step-by-step guide in install and setup Netbeans Integrated Development Environment (IDE) for Openbravo ERP development.
"Netbeans is a free, open-source Integrated Development Environment for software developers. You get all the tools you need to create professional desktop, enterprise, web, and mobile applications with the Java language, C/C++, and even dynamic languages such as PHP, JavaScript, Groovy, and Ruby. The NetBeans IDE is easy to install and use straight out of the box and runs on many platforms including Windows, Linux, Mac OS X and Solaris.", according to Netbeans's community. For more general or technical information concerning the Netbeans IDE, please visit:
- Netbeans Documentation
- Netbeans Community
- Netbeans Resources and Tutorials
Some of the features of using Netbeans can be read in the Netbeans IDE Features page.
Minimum requirements
First, it is important to set up the environment in which Openbravo ERP works correctly, i.e.:
- PostgreSQL or Oracle database
- Sun Java Development Kit (JDK)
The following packages are included in the 'Java' edition of Netbeans and it is not necesary to download it. But at your option, you can use your own packages.
In addition, a system with a minimum of 1GB of memory is required.
As your version control system you can either use Mercurial or Subversion clients both plugins are included by default in Netbeans. But it is necesary to install Mercurial or Subversion first.
Netbeans IDE
Download the latest version of the Netbeans IDE and select the edition 'Java'. This edition comes with support for Java Web and EE development and includes the Tomcat application server.
Before getting started
Before getting started, please follow these few tips to configure properly Netbeans for Openbravo ERP development.
You can tune Netbeans performance and avoid OutOfMemoryExceptions by editing and overwriting the file config/netbeans.conf and add the following options to the netbeans_default_options property:
-J-Xms40m -J-Xmx1024m -J-XX:PermSize=32m -J-XX:MaxPermSize=256m
If you prefer another look and feel for the Netbeans environment add the following option to the netbeans_default_options property for example to select the default java Metal look and feel:
--laf javax.swing.plaf.metal.MetalLookAndFeel
Checking out Openbravo ERP source code
Mercurial
To get the sources of Openbravo ERP you must clone the source repository the Openbravo ERP repositories are published in Openbravo Mercurial Repositories Index.
- In Team -> Mercurial -> Clone Other... type the URL of the repository you want to clone and press Next >.
- Select the default Push and Pull paths, usually you will want to use the same paths of the repository you are clonning. And after press Next >.
- Select the destination directory, the clone name and press Finish. We recomend to follow a directory structure similar to the image. Create an empty parent folder that will contain all the Netbeans project files and name it for example openbravo, and inside this folder clone the mercurial repository and name it for example main or the name of the repository you are cloning.
- Press Yes to add to the .hgignore file all extensions of files that any Merge or Revert Mercurial my generate.
After all these steps you will have a clone of the Openbravo ERP repository and can start installing Openbravo ERP.
Installing Openbravo ERP
Before importing Openbravo ERP projects you must configure and install Openbravo ERP. Here there is the minimum steps to follow to get a working Openbravo ERP installation. There is a complete guide to install Openbravo ERP in the | Openbravo ERP Installation guide.
- Edit Tomcat System variables. If you are using the Tomcat Application server installed by Netbeans, be sure that the variables CATALINA_BASE and CATALINA_HOME points to the directories Netbeans installed the Tomcat application server and the web applications root. You can find the folders for CATALINA_BASE and CATALINA_HOME in the Services tab Servers -> Apache Tomcat 6.0.18 and select Properties.
For example:
export JAVA_HOME=/usr/lib/jvm/java-6-sun export CATALINA_BASE=/home/ubuntu/.netbeans/6.7/apache-tomcat-6.0.18_base export CATALINA_HOME=/usr/local/apache-tomcat-6.0.18 export CATALINA_OPTS="-Djava.awt.headless=true -Xms384M -Xmx1024M -XX:MaxPermSize=256M" export ANT_OPTS="-Xmx1024M -XX:MaxPermSize=256M"
- Edit Openbravo.properties file. Take special care in the properties related to the database connection and to the paths and URLs of the Openbravo ERP application
- Execute the installation. Be sure that you have ant properly installed. You can use the ant files installed by Netbeans that are located in the subdirectory java2/ant/bin of the Netbeans installation directory. To install Openbravo ERP execute for example the following ant task:
ant install.source
Importing Openbravo ERP projects
After Openbravo ERP is properly installed you can start importing the Netbeans projects to develop Openbravo ERP. Start Netbeans and follow the same order of this tutorial because of the dependencies between projects. We recommend to follow the same directories structure shown in this tutorial for the projects.
Openbravo Core
- In the menu, select File -> New Project... In this window select the Category Java, the project type Java Project with Existing Sources and press Next >.
- Select the Project Name, the Project folder and press Next >.
- Add the sources folder that appear in the image and press Finish.
- In the project properties go to the category Libraries and in the tab Compile add the .jar files that appear in the image and press OK.
Openbravo WAD
- In the menu, select File -> New Project... In this window select the Category Java, the project type Java Project with Existing Sources and press Next >. Select the Project Name, the Project folder and press Next >.
- Add the sources folder that appear in the image and press Finish.
- In the project properties go to the category Libraries and in the tab Compile add the Projects and .jar files that appear in the image and press OK.
Openbravo Trl
- In the menu, select File -> New Project... In this window select the Category Java, the project type Java Project with Existing Sources and press Next >. Select the Project Name, the Project folder and press Next >.
- Add the sources folder that appear in the image and press Finish.
- In the project properties go to the category Libraries and in the tab Compile add the Projects and .jar files that appear in the image and press OK.
Openbravo Main Project
- In the menu, select File -> New Project... In this window select the Category Java, the project type Java Project with Existing Sources and press Next >. Select the Project Name, the Project folder, check the box Set as Main Project and press Next >.
- Add the sources folder that appear in the image and press Finish.
- In the project properties go to the category Libraries and in the tab Compile add the Projects and .jar files that appear in the image and press OK. The Projects to add are all the previous imported projects, and the Libraries are all jar files of the directories lib/runtime, lib/build and src-db/database/lib.
After importing all these four projects you will have a fully featured development environment for Openbravo ERP. The general aspect of your ID should look like this image_
Compiling and building Openbravo ERP from Netbeans
To build Openbravo ERP there exist an ant script that provides a large list of tasks and options that allow to build Openbravo ERP and execute several maintenance tasks related to the development. You can find all these tasks in detail in the Development Build Tasks document.
These ant tasks can be executed from the command line or from the Netbeans environment and even create shortcuts in Netbeans to execute these ant tasks.
To execute the ant tasks from the Openbravo ERP environment go to the Files tab and select the build.xml file that is in the root directory of the Openbravo ERP sources. After this file is selected, in the window Navigator will appear all the available targets. You can select one target and select Run Target to execute the target or Create Shortcut... to create a shortcut in the menu or in the toolbar to execute quickly the selected target.
When executing an ant target all the results will be displayed in the Output window. In the following image there is an example of the execution progress of the compile.complete.deploy target.
Running Openbravo ERP
To run Openbravo ERP you only have to start the Tomcat Application Server. With Netbeans you can manage your Tomcat Application Server. Go to the Services tab, open the node Server and select the Tomcat Application Server. From here you can start, stop, open a browser... And you can also edit from here the Tomcat Application Server properties.
Debugging Openbravo ERP
To debug with Netbeans, first you have to start the Tomcat Application Server in debug mode. To do this go to the Services tab, open the node Servers, select the Tomcat Application Server and execute it in Debug mode. By default the Tomcat Application Server debugger transport is configured to use the socket port 11555, but you can change these settings selecting the Tomcat Application Server and execute Properties. In this window go to the Startup tab and modify the Debugger Transport settings.
When starting Tomcat Application Server in debug mode, two output windows will appear, one with the Tomcat Application Server log output and the other with the console output. Wait until the Tomcat Application Server starts up and in the Debug menu, select Attach Debugger.... In this window select the debugger transport you used to configure your Tomcat Application Server, and if the Tomcat Application Server is located in other machine, edit also the host name. Press OK and the debug session will start. To stop the debug session press the Stop button or select the menu option Debug -> Finish Debugger Session.
Support
For any question or doubt regarding Netbeans IDE installation and setup, post them in Openbravo Developers forum or join #openbravo IRC channel in Freenode.