Skip to main content
The following instructions are for creating a Java algorithm using the NetBeans IDE. NetBeans can be downloaded for free from netbeans.org.

Create a new algorithm project using NetBeans

  1. Create a new project for the Java algorithm by selecting File > New Project from the NetBeans menu. Java New Project
  2. Under Categories, select Java. Then under Projects, select Java Class Library, and then press the Next button. Java New Project Dialog
  3. Enter the name of the project and the save location, and then press the Finish button. Java New Java Class Library Dialog
  4. Right-click on Libraries and select Add JAR/Folder. Java Add Jar Menu
  5. Locate PHXSolverInfrastructure.jar in the Algorithm Developer Tools directory. Typically: "C:\Program Files\Phoenix Integration\Algorithm Developer Tools" Java Add Jar Dialog
  6. Right-click on Source Packages and select New > Java Class. Java New Java Class Menu
  7. Name the algorithm class name and specify its package, then press the Finish button. Java New Java Class Dialog
  8. In the algorithm file, add:
    after the class name, e.g., Java Implements IAlgorithm
  9. Right-click on IAlgorithm and select Insert Code, then Implement Method: Java Insert Code Java Implement Method Menu
  10. Click the checkbox next to IAlgorithm and IDisposable, then click the Generate button. Java Generate Implement Methods
  11. It is recommended that each algorithm have its own GuidAttribute to uniquely identify the algorithm. To add a GuidAttribute to the algorithm, place attibute before the class definition.
    Java Add GUID New GUIDs can be generated using Create a GUID or some other similar tool.

Conclusion

The base class for the Java algorithm has now been implemented. The rest of the guide is based on .NET, but the major differences for Java are that properties use get property name and methods start with lowercase letters. Java algorithms install to the same location as the .NET algorithms, and the build file can be modified to move the algorithm to the correct location using the ant copy task.

Add manifest file for algorithm

A manifest file must be added to tell the Optimization Tool which JAR files should be searched for implementations of IAlgorithm. To add the manifest:
  1. Right-click on the project in NetBeans and select New > Other from the context menu.
  2. Select Other under Categories: and Empty File under File Types: and press the Next button.
  3. Name the file manifest.phx and press Finish.
  4. The file should be created in the project’s base directory. Open the manifest file and enter the name of the JAR file output by the algorithm project. A single manifest file can specify multiple files that contain IAlgorithm implementations, but only one file name should be specified per line.

Add algorithm copy to the Java algorithm build process

The algorithm can be moved to a location where the Optimization Tool can locate it automatically by adding the following code to the algorithm’s build.xml.