September 30, 2010

Quick Maximo Development Environment Setup

This entry is part of the Maximo Java Development series.

This is the quickest and simplest procedure that I know to setup an Eclipse environment to develop Java customizations for IBM Maximo products.


Eclipse Installation

The first step is to install Eclipse on the development system.
Download Eclipse 3.5 from Eclipse website.
Extract the downloaded zip file into a local folder (e.g. C:\Eclipse).


Java Runtime Environment

Eclipse requires a Java VM to run. If you try to launch Eclipse (C:\Eclipse\eclipse.exe) and you don't have a suitable JVM installed you will get the following error.


The best approach is to use the Java Virtual Machine (JVM) embedded in the application server in which Maximo runs. This ensures that you are using the right version of JRE.
The JRE must be copied into C:\Eclipse\jre. For WebShpere application server it is located in [WebSphere]\AppServer\java\jre folder.
After this, try to execute C:\Eclipse\eclipse.exe to ensure that everything is ok.


Configuring Eclipse for Maximo development

The right Java compiler must be selected:
  • Maximo 6: Java 1.4
  • Maximo 7: Java 1.5
  • Maximo 7.5: Java 1.6
Set it in Eclipse preferences: Windows > Preferences > Java > Compiler > Compile compliance level.



Project Setup

Create an empty Java project.

Extract [SMPDIR]\maximo\deployment\default\maximo.ear into a folder named maximo in your workspace.
Refresh project tree in Eclipse (F5).

Add the following jars to the project classpath: Project > Properties > Java Build Path > Libraries > Add Jars.
  • maximo/lib/*.jar
  • maximo/businessobjects.jar

Create a class named AssetCust in src\custom\app\asset (package custom.app.asset) and paste the following code into it.

package custom.app.asset;

import java.rmi.RemoteException;

import psdi.app.asset.Asset;
import psdi.mbo.MboSet;
import psdi.util.MXException;

public class AssetCust extends Asset {

  public AssetCust(MboSet ms) throws MXException, RemoteException {
    super(ms);
  }

  public void save()throws MXException, RemoteException {
    super.save();  
    int id = getInt("ASSETID");
    String desc = getString("DESCRIPTION");
    System.out.println("Saving Asset ID=" + id + " desc=" + desc);
  }
}

The custom Mbo class gets quickly compiled and is ready to be deployed on your Maximo server.


AppBean development

If you need to develop application customization you need to add some more libraries to your project classpath.
The first one is the j2ee.jar file which can be found in [SMPDIR]\maximo\applications\maximo\lib folder.
The second library must be built manually. If you go in the folder where you extracted the maximo.ear file, you will see a maximouiweb.war file. Extract this file (it is a zip file) to a directory named maximouiweb. Refresh project tree in Eclipse (F5) and include maximouiweb.war\WEB-INF\classes class folder to your classpath.