# Implementing a Processing app inside another one

**URL:** <https://discourse.processing.org/t/implementing-a-processing-app-inside-another-one/44920>\
**Category:** Coding Questions\
**Created:** [August 10, 2024, 2:30pm UTC](https://discourse.processing.org/t/implementing-a-processing-app-inside-another-one/44920 "2024-08-10T14:30:32Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [August 14, 2024, 2:06am UTC](https://discourse.processing.org/t/implementing-a-processing-app-inside-another-one/44920/3 "2024-08-14T02:06:37Z")

</div>

The following is one technique that could be used to open your slot machine sketch inside of another sketch. This demo requires that you have ‘processing-java’ installed, which is a command line app: [https://github.com/processing/processing/wiki/Command-Line](https://github.com/processing/processing/wiki/Command-Line). You can then use Processing’s _exec()_ to run your sketch by supplying the sketch’s folder location. I used macos to design and run this demo.

```auto
import java.io.*;

int _wndW = 400;
int _wndH = 300;

Process proc = null;

void setup() {
  size(_wndW, _wndH);
  surface.setTitle("Space Casino");
  background(0);
  stroke(0);
  strokeWeight(3.0);
}

void draw() {
  fill(0, 255, 0);
  rect(100, 100, 150, 30, 15);
  fill(0);
  textSize(18.0);
  textAlign(CENTER, CENTER);
  text("Run sketch", 100, 98, 150, 30);
}

void mousePressed() {
  if ((mouseX >= 100) && (mouseX <= 100 + 150) && (mouseY >= 100) && (mouseY <= 100 + 30)) {
    try {
      proc = exec("/usr/local/bin/processing-java", "--sketch=/Users/yourName/Documents/Processing/SpaceCasinoSlotMachine", "--run");

      BufferedReader out = new BufferedReader(new InputStreamReader(proc.getInputStream()));
      BufferedReader err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
      String s = null;
      while ((s = out.readLine()) != null) {
        println(s);
      }
      while ((s = err.readLine()) != null) {
        println(s);
      }
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/implementing-a-processing-app-inside-another-one/44920)._
