Exported processing executable doesn't start from command line


I made a tool with processing I want to start from Windows command line.
It works when I set the current working directory to the .exe location, and then start it by typing its name:

cd C:\path\to\executable\

However, it doesn’t start if it’s called from its absolute path:


Steps to reproduce:

  • Open an example code, like “Array”:
 * Array. 
 * An array is a list of data. Each piece of data in an array 
 * is identified by an index number representing its position in 
 * the array. Arrays are zero based, which means that the first 
 * element in the array is [0], the second element is [1], and so on. 
 * In this example, an array named "coswave" is created and
 * filled with the cosine values. This data is displayed three 
 * separate ways on the screen.  

float[] coswave; 

void setup() {
  size(640, 360);
  coswave = new float[width];
  for (int i = 0; i < width; i++) {
    float amount = map(i, 0, width, 0, PI);
    coswave[i] = abs(cos(amount));

void draw() {

  int y1 = 0;
  int y2 = height/3;
  for (int i = 0; i < width; i++) {
    line(i, y1, i, y2);

  y1 = y2;
  y2 = y1 + y1;
  for (int i = 0; i < width; i++) {
    stroke(coswave[i]*255 / 4);
    line(i, y1, i, y2);
  y1 = y2;
  y2 = height;
  for (int i = 0; i < width; i++) {
    stroke(255 - coswave[i]*255);
    line(i, y1, i, y2);
  • Export this sketch to a Windows executable with embedded Java platform.
  • Verify that the .exe generated file can be started with doubleclicking on it :

Then, with cmd.exe, try starting the executable with just its name or absolute path:

Any other program can be started with its absolute path.


Ok, after more research the executable works only if the current working directory is the executable folder.
This can be proved by creating a shortcut to the executable. By default, the current working directory is the executable folder and it works.
However, if it’s changed, it doesn’t work anymore.

Any way to get around this issue ?

1 Like

As a workaround, I’ve written (in C language) a small wrapper that receives as argument the path to the processing’s executable to launch.
It changes the current working directory to its folder just before executing it.

If additional arguments are given, they are redirected to the executable.

Here is the code, which can be compiled with Dev-C++:

#include <stdio.h>
#include <unistd.h>
#include <libgen.h>

int main(int argc, char **argv)
   if(argc >= 2) // we received at least the name of an executable to start
	   // Extracting its directory name
	   char new_working_directory[1000];
	   strcpy(new_working_directory, argv[1]);
	   // Changing current working directory
	   printf("Changing WD to: %s\r\n", new_working_directory);
	   // Generating command to start the executable with its parameters
	   char command[1000];
	   strcpy(command, argv[1]);
	   int i;
	   for(i = 2; i < argc; i++)
		   strcat(command, " \"");
		   strcat(command, argv[i]);
		   strcat(command, "\"");
	   printf("Executing %s\r\n", command);
	   return system(command);
   return 1;

However, it’s a workaround and it would be better if the processing’s generated executable could be started no matter the current working directory.