# Using Processing Core Library like a console application, no window

**URL:** https://discourse.processing.org/t/using-processing-core-library-like-a-console-application-no-window/10800
**Category:** Processing
**Created:** [May 1, 2019, 12:53am UTC](https://discourse.processing.org/t/using-processing-core-library-like-a-console-application-no-window/10800 "2019-05-01T00:53:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![TheFoxarmy](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@TheFoxarmy](https://discourse.processing.org/u/TheFoxarmy)
#### Post date: [May 1, 2019, 12:53am UTC](https://discourse.processing.org/t/using-processing-core-library-like-a-console-application-no-window/10800/1 "2019-05-01T00:53:34Z")

</div>

Hello, I’d like to use the processing core library, however, I don’t actually want to use the processing window or `draw` function at all. I’m using processing because the `PImage` class and some other utilities are very useful, but this is a console application and I don’t need any of the other features. I’ve got a class that extends `PApplet`, and its constructor calls `sketchPath()` and passes the path of the current running jar so that I can call `loadImage()` without calling `setup()` so a window doesn’t have to be created. This works almost perfectly, however, I’m encounter issues when running headless on Linux server, and I understand why, I just don’t know what to change to disable all the display type stuff. This is the error:

```auto
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using '0' as the value of the DISPLAY variable.
        at java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
        at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:102)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.desktop/sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:61)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:101)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:83)
        at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:129)
        at java.desktop/sun.awt.X11.XToolkit.<clinit>(XToolkit.java:232)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:588)
        at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)
        at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:286)
        at processing.core.PApplet.loadImage(PApplet.java:5564)
        at processing.core.PApplet.loadImage(PApplet.java:5480)
        at ImgDiff.<init>(ImgDiff.kt:9)
        at ImgDiffKt.main(ImgDiff.kt:31)

```

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [May 1, 2019, 4:38pm UTC](https://discourse.processing.org/t/using-processing-core-library-like-a-console-application-no-window/10800/2 "2019-05-01T16:38:37Z")

</div>

Hello,

Maybe you can just use the file `PImage.java` in your project :

- [PImage.java on GitHub](https://github.com/processing/processing/blob/349f413a3fb63a75e0b096097a5b0ba7f5565198/core/src/processing/core/PImage.java)

---

<div class="post-metadata">

### Author: ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)
#### Post date: [May 1, 2019, 9:02pm UTC](https://discourse.processing.org/t/using-processing-core-library-like-a-console-application-no-window/10800/3 "2019-05-01T21:02:39Z")

</div>

I’m not sure what method are you using, but I made myself `ProcessingTest.java` class that has only this:

```auto
import processing.core.PImage;
import processing.core.PApplet;
public class ProcessingTest{

	public static void main(String[] args){
		PApplet thing = new PApplet();
		thing.sketchPath();
		PImage test;
		test=thing.loadImage("/home/architector4/Pictures/test.png");
	}

}

```

And it compiles, loads and runs just fine without X11.

If something like this doesn’t work for you, could you please provide a minimum viable example i.e. the smallest amount of code that fails with that error?
