# Run code from terminal \[Linux\]

**URL:** <https://discourse.processing.org/t/run-code-from-terminal-linux/44774>\
**Category:** Beginners\
**Created:** [July 16, 2024, 2:01pm UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774 "2024-07-16T14:01:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 16, 2024, 2:01pm UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774/1 "2024-07-16T14:01:47Z")

</div>

Hi,

is it possible to run code directly in the terminal?

Something like this:  
`:~$ processing> size(400, 400); rect(120, 80, 50, 50);`

I read in a previous post that I need to install “processing-java”, but I can’t find it.  
[I use Processing 4.3 on Linux, gnome-terminal 3.44.0]

Thank you,  
f

---

<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:** [July 16, 2024, 8:28pm UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774/2 "2024-07-16T20:28:36Z")

</div>

This is in the Wiki in the Processing 3.5.4 repository:

> **[Command Line](https://github.com/processing/processing/wiki/Command-Line)**
>
> Source code for the Processing Core and Development Environment (PDE) - processing/processing

I did not see it here:

> **[Home](https://github.com/benfry/processing4/wiki)**
>
> Processing 4.x releases for Java 17. Contribute to benfry/processing4 development by creating an account on GitHub.

Give it a try and share your experience.

`:)`

---

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 17, 2024, 12:52am UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774/3 "2024-07-17T00:52:45Z")

</div>

Thank you.  
I had already seen the first link, but I didn’t understand where I should download “processing-java” for Linux.  
Then…I realized it’s in the Processing download folder: in fact it is present and it works.  
I can run a sketch directly in the terminal by specifying the folder and file name, and it works fine.  
But…what I would like to do is run the code by writing it directly in the terminal, not execute a file. I wasn’t able to do this and I don’t understand if it can be done.

Bye,  
f

---

<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:** [July 18, 2024, 2:07pm UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774/4 "2024-07-18T14:07:04Z")

</div>

I’m not sure that you can achieve what you want to do with Processing source code, but you might be able to do it with java code. I’ve also seen it done with objc on a Mac. Reference: [https://docs.groupdocs.com/viewer/java/how-to-create-minimal-java-app/](https://docs.groupdocs.com/viewer/java/how-to-create-minimal-java-app/)

This is example code that runs on a mac; you’ll have to try it on Linux:

```auto
echo 'public class App {
    public static void main(String[] args) {
      System.out.println("Hello, World!");
    }
}
' > App.java | javac -d . App.java | java -classpath . App

```

---

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 18, 2024, 5:23pm UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774/5 "2024-07-18T17:23:06Z")

</div>

> [@svan](#):
>
> try it on Linux

Thank you,  
it works fine on Linux:

```auto
x@x:~$ echo 'public class App {
    public static void main(String[] args) {
      System.out.println("Hello, World!");
    }
}
' > App.java | javac -d . App.java | java -classpath . App
Hello, World!
x@x:~$

```

So, how should I use it to run, for example, this simple code below directly in the linux terminal?

```auto
size (600, 600);
strokeWeight(10);
point(300, 200);
strokeWeight(1);

```

Thank you,  
f

---

<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:** [July 18, 2024, 5:49pm UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774/6 "2024-07-18T17:49:36Z")

</div>

> [@fra](#):
>
> So, how should I use it to run, for example, this simple code below directly in the linux terminal?

You need to continue to use _processing-java_, using this procedure:

1. Create a folder with the same name as the sketch (eg, testSketch)
2. In Terminal change to that directory.
3. Copy/paste this code:

```auto
echo 'size (600, 600);
strokeWeight(10);
point(300, 200);
strokeWeight(1);' > testSketch.pde | processing-java --sketch=/Users/yourName/testSketch --run

```

The code that you enter on the command line will be redirected to your sketch file, and then it will be run by processing-java after entering the name of its folder. This was done on a mac; you will have to test it on Linux.

Hit return and you should see this output:

 ![cmd](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/2/022e121ed5adb31e975f3db8a7cf78d98414e63e.png)

---

<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:** [July 19, 2024, 1:04am UTC](https://discourse.processing.org/t/run-code-from-terminal-linux/44774/7 "2024-07-19T01:04:47Z")

</div>

This worked on W10 command-line:

```auto
d:\test>echo size(530,530);for(int j=0,m=23,r=0;j^^^<m*m;r=choice(2)*m)line(j%m*m+r,j/m*m,j%m*m+m-r,j++/m*m+m); > test.pde | processing-java --sketch=d:\test --run

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/d/6dca1b72442dfa20ddbe03020100671d2d4c8700.png)

I had to create a folder `d:\test`

See here for the `^^^`:  
[Quotes, Escape Characters, Delimiters - Windows CMD - SS64.com](https://ss64.com/nt/syntax-esc.html)

Output:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/7/e7497fac64e231cdbcfc3fdc85e06c50fb186b5a.png)

`:)`
