Develop in Eclipse


You want to develop and run your application in Eclipse.


Download the latest version of Eclipse here.

Create a new project. On the Java Settings page, go to the "Libraries" tab and add the agi.parallel.client-[version].jar to the project. It can also be added later by using Project > Properties > Java Build Path > Libraries > Add External JARS

Configure Eclipse Step 1

Optionally configure Javadoc. On the "Libraries" tab, expand agi.parallel.client-1.4.0.jar and double click on the Javadoc location.

Configure Eclipse Step 2

In the Javadoc for 'agi.parallel.client-1.4.0.jar' panel, select the "Javadoc in archive" option and browse to the location of agi.parallel.javadoc-1.4.0.jar. This is located at [PathToSTKScalabilityApiJavaFolder]\Documentation\agi.parallel.javadoc-1.4.0.jar

Copy and paste to the project.

import agi.parallel.client.ClusterJobScheduler;
import agi.parallel.client.IJobScheduler;
import agi.parallel.client.Job;
import agi.parallel.infrastructure.Task;

public class EclipseWithStkScalability {
    public static void main(String[] args) {
        IJobScheduler scheduler = new ClusterJobScheduler("localhost");
        try {
            Job job = scheduler.createJob();
            Task task = new MyTask();
            System.out.println("Result = " + task.getResult());
        } finally {

    public static class MyTask extends Task {
        public void execute() {
            System.out.println("Line 1");
            System.out.println("Line 2");

Next, compile the project as a jar and set up Eclipse to run the jar instead of the class files directly.

Go to File > Export > Java > JAR file

Configure Eclipse Step 3

Save the jar. Take note of the location of the JAR file that you specified.

Configure Eclipse Step 4
Note Note

To run the application in Eclipse, the jar file needs to be rebuilt every time the source files are updated. For instructions to build the jar automatically, see details in the Discussion section.

The last step is to make sure that the Run configuration is configured to run the created jar file.

Go to Run > Run Configurations > Java Application. In the "Classpath" tab, click on "Add External Jars" and select the created jar above. Make sure to move the jar to the first entry in "User Entries."

Configure Eclipse Step 5

Finally, run the application.


One of the most common questions from developers relates to IDEs and tasks. Although the documentation gives instructions on how to compile applications using the command line, there is no reason IDEs can't be used to develop and debug tasks. The examples included in the developer kit also include Eclipse project files and ant scripts. To run the examples from Eclipse, import the example's project file into the Eclipse workspace.

Eclipse has the capability to automatically rebuild the jar file before every run to avoid the manual process of exporting the jar file each time a source file changes. To autobuild the jar file, run an ant builder that packages the project into a jar after each compilation. In Eclipse, right click on the project and click "Properties". On the properties page, go to the "Builders" tab, and add the ant buildfile. An ant script that can build the jar file will be needed. Included below is an example ant script that can be used as a template.

<project name="EclipseWithStkScalability" basedir="." default="package">
  <property name="" value="EclipseWithStkScalability.jar" />

  <property name="output.dir" value="ant" />
  <property name="bin.dir" value="${output.dir}/bin" />
  <property name="dist.dir" value="dist" />

  <target name="clean" description="Clean all generated output.">
    <delete dir="${output.dir}" />
    <delete dir="${dist.dir}" />

  <target name="prepare">
    <mkdir dir="${bin.dir}" />
    <mkdir dir="${dist.dir}" />
    <path id="project.classpath">
      <fileset dir="lib" includes="*.jar" />

  <target name="compile" depends="prepare" description="Compile source code.">
    <javac source="1.7" target="1.7" destdir="${bin.dir}" classpathref="project.classpath" includeantruntime="no">
      <src path="src" />

  <target name="package" depends="compile" description="Package the application into a jar, and copy all needed resources to the dist directory.">
    <!-- Copy library jars to the dist directory -->
    <copy todir="${dist.dir}" flatten="true">
      <path refid="project.classpath" />

    <!-- Build the jar file containing the application itself -->
    <copy todir="${bin.dir}">
      <fileset dir="src" excludes="**/*.java" />

    <pathconvert property="manifest.classpath" pathsep=" ">
      <path refid="project.classpath" />
      <flattenmapper />

    <jar destfile="${dist.dir}/${}">
      <fileset dir="${bin.dir}" />
        <attribute name="Class-Path" value="${manifest.classpath}" />
        <attribute name="Main-Class" value="EclipseWithStkScalability" />

  <target name="run" depends="package" description="Build and run the demo application.">
    <java fork="true" jar="${dist.dir}/${}" dir="${dist.dir}" />
    <!-- jvmarg line="" /> -->
Tip Tip

Note that the project.classpath property in this ant script is set to the lib directory of the project folder. You will have to copy agi.parallel.client-1.4.0.jar to the lib folder in order to use the ant file to compile and run.

Before closing the "Edit Configuration" panel, go to the "Targets" tab. On the "Manual Build" and "Auto Build" options, select the ant target that packages the project into a jar file. For the ant script above, this is the package target.

Configure ant autobuild

If done correctly, this configures Eclipse to build the jar automatically via ant during every compilation.

Tip Tip

If an error is given that the built jar cannot be found when trying to execute your program, try refreshing the project/package explorer view in Eclipse.

See Also

Other Resources

STK Scalability 1.4 API for Java