Set host working directory


You want to set the working directory of the host.


To set the host's working directory, set WorkingDirectory and pass the path of the desired working directory. The string will be resolved by expanding the string as an environment variable. For instance, "%TEMP%" will resolve to the full temporary directory path. The task will fail if the directory does not exist on the agent machine.

package stkscalabilitysdk.howto;

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

public class SetHostWorkingDirectory {
    public static void main(String[] args) {
        IJobScheduler scheduler = new ClusterJobScheduler("localhost");
        try {

            Job job = scheduler.createJob();
            job.addTask(new ReturnsWorkingDirectory());

            // Use the Windows variables to specify specific directories.

            System.out.println("Working Directory: " + job.getTasks().get(0).getResult());
        } finally {

         * The output of the application should resemble:
         * Working Directory: C:\Users\jdoe\AppData\Local\Temp

    private static class ReturnsWorkingDirectory extends Task {
        public void execute() {

By default the working directory of the host process is the agent bin folder. There are some cases where a task needs a user defined working directory. The most common of these cases is that the application assumes a relative path to data. Sometimes this can be avoided by modifying the application itself. However, setting the working directory is an option in cases where modifying the application is not possible.

See Also

Other Resources

STK Scalability 1.4 API for Java