# How to send an argument when using processing-java

**URL:** <https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691>\
**Category:** Coding Questions\
**Created:** [January 3, 2026, 10:37pm UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691 "2026-01-03T22:37:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [January 3, 2026, 10:37pm UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/1 "2026-01-03T22:37:46Z")

</div>

I can run a Processing sketch from the command line using  
processing-java --sketch=pathtosketchfolder --run  
But, how do I send an argument, such as the value of a variable, at the same time?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 3, 2026, 10:51pm UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/2 "2026-01-03T22:51:39Z")

</div>

I have no experience doing this but found the following when ‘processing-java‘ was typed into Terminal on MacOS:

```bash
The --build, --run, --present, or --export must be the final parameter
passed to Processing. Arguments passed following one of those four will
be passed through to the sketch itself, and therefore available to the
sketch via the 'args' field. To pass options understood by PApplet.main(),
write a custom main() method so that the preprocessor does not add one.

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 4, 2026, 4:46am UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/3 "2026-01-04T04:46:49Z")

</div>

Hello @paulstgeorge,

What version of Processing and OS are you using?

I use `processing cli` with Processing 4.4.10 and W10.

`processing-java`  
is now replaced with  
`processing cli`

> [@paulstgeorge](#):
>
> But, how do I send an argument, such as the value of a variable, at the same time?

See this reference for `processing-java.exe` :  
[https://github.com/processing/processing/wiki/Command-Line#adding-command-line-arguments](https://github.com/processing/processing/wiki/Command-Line#adding-command-line-arguments)

References:  
_[Processing 4 processing-java binary? - #10 by stefterv](https://discourse.processing.org/t/processing-4-processing-java-binary/47498/10)_  
_[processing cli --help links to old repository · Issue #1366 · processing/processing4 · GitHub](https://github.com/processing/processing4/issues/1366)_

`:)`

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [January 4, 2026, 9:36am UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/4 "2026-01-04T09:36:29Z")

</div>

That, plus the code from [Command Line · processing/processing Wiki · GitHub](https://github.com/processing/processing/wiki/Command-Line) worked perfectly, thanks.  
I had trouble using settings(), so put the extra code in setup()

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [January 4, 2026, 9:42am UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/5 "2026-01-04T09:42:04Z")

</div>

Hello and happy new year @glv  
I am using Processing 4.4.7 and Mac OS  
I have looked at [Environment / Processing.org](https://processing.org/environment/#command-line-interface-cli)

But I still need more help with the syntax of the commands, and with the code to add to the sketch (please)…

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 4, 2026, 10:49pm UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/6 "2026-01-04T22:49:00Z")

</div>

Hello @paulstgeorge,

And Happy New Year!

> [@paulstgeorge](#):
>
> But I still need more help with the syntax of the commands, and with the code to add to the sketch (please)…

Hopefully something here can help.  
Keep in mind that there are differences between W10 and macOS.

See:  
_[CLI: `--help` not working on Windows 10/11 · Issue #1306 · processing/processing4 · GitHub](https://github.com/processing/processing4/issues/1306)_

W10 command-line:

`D:\>processing cli --sketch="D:\Users\GLV\Documents\P4\cli_args_1_0_0" --run test 123 3.1415927`

This works for Processing 4.4.10 and W10:

```auto
// This is what I used for Windows 10 Processing 4.4.10:
// D:\>processing cli --sketch="D:\Users\GLV\Documents\P4\cli_args_1_0_0" --run test 123 3.1415927
  
void setup()
  {
  size(300, 300);
  background(255, 255, 0);
  fill(0);
  textSize(24); 
  
  // For testing only since you don't have a console for errors in this example
  //String args [] = {"test", "123", "3.141592"}; 
  
  if (args != null) 
    {
    background(0, 255, 0);
    fill(0);
    textSize(24);
    String s = "Arguments passed: " + args.length + '\n';
    for(int i = 0; i<args.length; i++)
      {
      s = s+ args[i] + '\n';  
      }
    text(s, 20, 20, width-20, height-20);  
    }
  noLoop();  
  }

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/5/85fba6437a03142670608ea5c002e812eb27912a.png)

`processing-java` \< Try this in place of this for your environment:  
`processing cli`

I do not have Processing 4.4.7 and a _macOS_ to test this on and using Processing 4.4.10.

Can you try this with version 4.4.7 and 4.4.10 on your macOS?  
`processing cli` _may_ work with Processing 4.4.7… give it a try!

Be mindful of folder you are working from:  
_[Environment / Processing.org](https://processing.org/environment/#command-line-interface-cli)_  
_[Alternate Processing Editor Using processing-java.exe on the Command line - #8 by svan](https://discourse.processing.org/t/alternate-processing-editor-using-processing-java-exe-on-the-command-line/47530/8)_

`:)`

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [January 5, 2026, 7:02am UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/7 "2026-01-05T07:02:39Z")

</div>

Thanks,

I understand the command line and I understand the code used in setup(), but I don’t understand this:

> processing-java.exe \< Try this in place of this for your environment:  
> processing cli

Do I need to download and/or install something and then put it in the correct place?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 5, 2026, 8:14am UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/8 "2026-01-05T08:14:40Z")

</div>

On MacOS there are currently a couple of ways that you can use the command line to run a Processing sketch and you are being asked to try the alternate method. Currently you are using _processing-java_ which requires a Terminal command which looks like this:

```bash
% processing-java –-sketch=path/to/your/sketchFolder –-run your argument

```

What you are being asked to try is to access _Processing.exe_ in the app bundle and then launch _cli_ from there, which means that you need two lines of code instead of one:

```bash
% cd /Applications/Processing.app/Contents/MacOS

```

then a second command to launch the Processing executable

```bash
% ./Processing cli --sketch=path/to/your/sketchFolder --run your argument

```

For Mac users the first is pretty simple; however, the other platforms use different methods and don’t have this option. As of v.4.4.10 we still have the option to install _processing-java_ from the Tools menubar item:

 ![pj](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/4/e4fd813261da3aab786e68723043e3c3ebea4c8e.png)

If that option were to be taken away in the future, Mac users would be forced to use _processing cli_ from the Processing.app bundle. If you don’t already know, you can do a right click on your Processing.app and see the contents of the bundle. If you look in the Contents/MacOS folders you should see the main Processing.exe file that you are being asked to try. On the other hand, _processing-java_ is a small 4k executable file which lives at /usr/local/bin on my system. I think that it likely gets installed there when the menu item is selected.

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [January 5, 2026, 9:05am UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/9 "2026-01-05T09:05:16Z")

</div>

@svan  
Excellent. That all makes sense, and works perfectly. And I have two ways to use the command line. This could be useful if one of the options is removed.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 5, 2026, 6:11pm UTC](https://discourse.processing.org/t/how-to-send-an-argument-when-using-processing-java/47691/10 "2026-01-05T18:11:27Z")

</div>

> [@paulstgeorge](#):
>
> but I don’t understand this:
> 
> > processing-java.exe \< Try this in place of this for your environment:  
> > processing cli

You were already using `processing-java` (initial post) and I was using `processing cli` examples and suggesting to try it in my examples.

I see that this is all sorted out!

I shared my feedback in this issue:

> <https://github.com/processing/processing4/issues/1366>
>
> \### Most appropriate sub-area of Processing 4?
> 
> Utilities
> 
> \### Processing versio…n
> 
> 4.4.10, confirmed on build from main branch
> 
> \### Operating system
> 
> Linux
> 
> \### Bug description
> 
> Running \`processing cli --help\` from the command line links to https://github.com/processing/processing/wiki/Command-Line.
> The page explains the behavior of the processing-java command, although the flags available seem to match. 
> The existence of the page linked can confuse users as it did me. 
> 
> \### Steps to reproduce this
> 
> 1. install processing
> 
> 2. run \`processing cli --help\`
> 
> 3. read the bottom of the output
> 
> 
> \### snippet
> 
> \_No response\_
> 
> \### Additional context
> 
> \_No response\_
> 
> \### Would you like to work on the issue?
> 
> Yes, I’d like to help with this

`:)`
