# Running Processing in Headless Mode (On a Mac)

**URL:** <https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457>\
**Category:** Coding Questions\
**Created:** [September 11, 2018, 11:03am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457 "2018-09-11T11:03:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsomani95](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rsomani95/32/1539_2.png) [@rsomani95](https://discourse.processing.org/u/rsomani95)\
**Post date:** [September 11, 2018, 11:03am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/1 "2018-09-11T11:03:08Z")

</div>

I want to run Processing sketches from the terminal, and not have a display window show up.  
Currently, I can run processing from the terminal using the `processing-java` command and save my files where I’d like to.

However, I’d like to run multiple such commands back to back without having to close the display window after every command, as it is the only thing that is keeping me from automating my workflow.

I have looked at [this](https://github.com/processing/processing/wiki/Running-without-a-Display) link, but it only works for Linux operating systems.

Is there way around this?  
Worst case scenario that I can see is to import all the processing functionality into Java and then run the java files from the terminal? If this is the case, I would appreciate any useful links/tutorials that you guys might have links to, as I would be doing something like this for the first time. I am an inexperienced Java programmer.

Thank you for your time and help.

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [September 11, 2018, 4:22pm UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/2 "2018-09-11T16:22:55Z")

</div>

Shameless self-promotion: here is a tutorial on using Processing as a Java library:

> **[Processing in Java](https://happycoding.io/tutorials/java/processing-in-java)**
>
> Learn how to use Processing as a Java library.

---

<div class="post-metadata">

**Author:** ![rsomani95](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rsomani95/32/1539_2.png) [@rsomani95](https://discourse.processing.org/u/rsomani95)\
**Post date:** [September 12, 2018, 12:30am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/3 "2018-09-12T00:30:18Z")

</div>

Would the `PApplet` work without a `settings()` function?  
Would it be possible to use Processing as a Java library and the save the output to a `PGraphics` file?

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [September 12, 2018, 1:01am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/4 "2018-09-12T01:01:33Z")

</div>

> [@rsomani95](#):
>
> Would the `PApplet` work without a `settings()` function?

I’m pretty sure you need to `settings()` function if you’re using Processing as a Java library.

> [@rsomani95](#):
>
> Would it be possible to use Processing as a Java library and the save the output to a `PGraphics` file?

Sure, depending on what you mean by `PGraphics` file.

The best thing to do is just try it out and see what happens.

---

<div class="post-metadata">

**Author:** ![rsomani95](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rsomani95/32/1539_2.png) [@rsomani95](https://discourse.processing.org/u/rsomani95)\
**Post date:** [September 12, 2018, 1:44am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/5 "2018-09-12T01:44:36Z")

</div>

I didn’t express what I meant regarding the `PGraphics` file well. Anyways, it doesn’t matter.

Interestingly, I found the solution I needed in the PDF Export Library for Processing. They have an option to save to PDF without opening the display window!

Thank you for your help @Kevin

---

<div class="post-metadata">

**Author:** ![SamBoadas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/samboadas/32/20554_2.png) [@SamBoadas](https://discourse.processing.org/u/SamBoadas)\
**Post date:** [March 30, 2025, 12:06am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/6 "2025-03-30T00:06:03Z")

</div>

Sir, no shame. I just tested your tutorial, yeah in 2025, 7 years later. And it does still work. It took me 15min to do what I wanted to do, youre a hero. Wherever you are I wish you good luck

---

<div class="post-metadata">

**Author:** ![SamBoadas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/samboadas/32/20554_2.png) [@SamBoadas](https://discourse.processing.org/u/SamBoadas)\
**Post date:** [March 30, 2025, 12:07am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/7 "2025-03-30T00:07:57Z")

</div>

Also, whenever someones search “Run Processing sketch without window” or “Run processing in the terminal” or something similar this forum entry its one of the top 3, so yeah, youve helpep a lot of people despite probably no one told you

---

<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:** [March 31, 2025, 2:02am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/8 "2025-03-31T02:02:17Z")

</div>

If you use the sketch format in the reference and a copy of '_core.jar’_ is placed in the sketch folder, the command line code (in Terminal) can be reduced to a one-liner: `java -cp "core.jar" MySketch.java`, obviating the need for the ‘javac’ line of code. As also noted in the reference, _core.jar_ is found in the Processing.app bundle at Contents/Java/core/library. On a Mac, bundle contents are shown by selecting the Processing.app and then right clicking and selecting ‘Show Package Contents’ from the popup menu. This method was not tested on other platforms.

**Source code in your favorite editor:**

```auto
import processing.core.PApplet;

 public class MySketch extends PApplet{

  public void settings(){
    size(500, 500);
  }
  
  public void setup(){
    surface.setTitle("Click on rectangle to change color.");
  }
  
  public void draw(){
    background(209);
    rect(mouseX -20, mouseY - 20, 40, 40);
  }
  
  public void mousePressed(){
    println("mouse pressed.");
    fill(random(255),random(255),random(255));
  }
  
  public static void main(String[] args){
    String[] processingArgs = {"MySketch"};
    MySketch mySketch = new MySketch();
    PApplet.runSketch(processingArgs, mySketch);
  }
}

```

_println()_ output is shown in Terminal and may be used for limited debugging. Hitting the up arrow will re-enter the last command so that you do not have to re-type it:  
`java -cp "core.jar" MySketch.java`

**Output:**

 ![out](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/2/722e1fc41115b057ed08bc9a2085c49b3232ada9.png)

---

<div class="post-metadata">

**Author:** ![SamBoadas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/samboadas/32/20554_2.png) [@SamBoadas](https://discourse.processing.org/u/SamBoadas)\
**Post date:** [March 31, 2025, 4:01am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/9 "2025-03-31T04:01:01Z")

</div>

It does work perfect. The link above has the same information (same method) and its 7 years old. However it doesnt answer the question of using all processing functionality and everything but without creating a window (We can clearly see a window being created here on settings). Why we want this? Maybe we’re using another type of window, maybe for OpenGL, or we’re only not using a window at all, just a terminal, but we want all processing power and utility (Like PGraphics, PImage, JSONObject, PVector, etc etc etc). There are plenty of reasons

---

<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:** [March 31, 2025, 6:03am UTC](https://discourse.processing.org/t/running-processing-in-headless-mode-on-a-mac/3457/10 "2025-03-31T06:03:39Z")

</div>

The following code does not put up a window and prints output to Terminal. Use command-Q to quit the app on a Mac.

```auto
import processing.core.PApplet;

 public class NoWindow extends PApplet{

  public void settings(){
  }
  
  public void setup(){
  surface.setVisible(false);
  println("product =",50*3);
  }
  
  public void draw(){   
  }
    
  public static void main(String[] args){
    String[] processingArgs = {"NoWindow"};
    NoWindow noWnd = new NoWindow();
    PApplet.runSketch(processingArgs, noWnd);
  }
}

```
