# Open console instead of window

**URL:** https://discourse.processing.org/t/open-console-instead-of-window/31040
**Category:** Project Guidance
**Created:** [July 4, 2021, 11:57am UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040 "2021-07-04T11:57:09Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [July 4, 2021, 11:57am UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/1 "2021-07-04T11:57:09Z")

</div>

Hi!

Is it possible to open a console window instead of default window? C++ style, where you can input text / values into it? How does that affect the setup() and draw()? How simple can you make it? I am planning to teach a friend simple coding and wanted to do the random number guessing game, but it would require on-screen buttons which are a pain to explain to a beginner.

Thank you!

Btw, do you have any interesting projects you did as a beginner? I need a large pool of simple projects (up to towers of hanoi difficulty), any suggestions would be nice. Thank you again and have a nice day!

---

<div class="post-metadata">

### Author: ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)
#### Post date: [July 4, 2021, 6:16pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/2 "2021-07-04T18:16:17Z")

</div>

> [@CodeMasterX](#):
>
> Is it possible to open a console window instead of default window? C++ style, where you can input text / values into it?

Is it necessary, then, to use Processing? You and your friend could install Python directly on a machine, and use that to get started with simple coding.

See the official [Python](https://www.python.org/) web site.

Also see [Number guessing game in Python 3 and C](https://www.geeksforgeeks.org/number-guessing-game-in-python/).

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [July 4, 2021, 8:49pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/3 "2021-07-04T20:49:27Z")

</div>

Yeah it is best if it is processing. He is relatively new to coding and he is in a course that requires java. So if he becomes familiar with processing, which is basically simplified java, it would be really helpful.

In any case, how can I open the terminal? I still think it would be interesting to know.

Thank you and have a nice day.

---

<div class="post-metadata">

### Author: ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)
#### Post date: [July 4, 2021, 9:25pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/4 "2021-07-04T21:25:26Z")

</div>

Just prior to my previous post, I tried to execute a simplified version of a number guessing game in Processing Python Mode. Since that environment uses Python 2, I used the `raw_input` function to prompt and attempt to collect user input. It raised an `EOFError`, probably because the Processing Development Environment attempts to keep going without waiting for the user’s input. That’s why I then suggested working outside the Processing Development Environment.

You could try such a strategy in Processing Java Mode to find out whether a similar error occurs. If it does, the best option might be to work with Java independently of Processing. … or perhaps another member of the Processing community may have found a means of overcoming this problem, and could report it here.

_EDIT (July 4, 2021):_

Well, I tried this in Processing Java Mode, and it would not accept input.

```auto
import java.util.Scanner;
Scanner num_inp = new Scanner(System.in);
System.out.println("Enter a number:");
String num_str = num_inp.nextLine(); // get input
System.out.println("You entered " + num_str); // display the input

```

☹

---

<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 4, 2021, 10:37pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/5 "2021-07-04T22:37:27Z")

</div>

Hello,

I tried it in Eclipse and works for this example:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/86589004f7b38d9598885232d296913095136739.png)

`:)`

---

<div class="post-metadata">

### Author: ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)
#### Post date: [July 4, 2021, 10:48pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/6 "2021-07-04T22:48:13Z")

</div>

Excellent! Thanks for saving the day, @glv. 😃

---

<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 4, 2021, 11:09pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/7 "2021-07-04T23:09:57Z")

</div>

Hello,

Eclipse can be a challenge and I still prefer the simplified interface of the Processing IDE when I code for fun.

This may help anyone that wants to take an adventure and use Eclipse:

> **[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: ![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 4, 2021, 11:33pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/8 "2021-07-04T23:33:37Z")

</div>

Hello,

There is always _javax.swing.JOptionPane_ for simple IO:

```auto
import javax.swing.JOptionPane;

int col;

void setup() {
  }

void draw() {
  background(col); 
  }

void keyPressed() {
  thread("MessageDialog_thread");
  } 

void MessageDialog_thread() {
  String strInp = JOptionPane.showInputDialog(null,"Enter a color 0 to 255:");
  col = int(strInp);
  JOptionPane.showMessageDialog(null, col, "Output", JOptionPane.PLAIN_MESSAGE);
  }

```

`:)`

---

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [July 5, 2021, 4:27pm UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/9 "2021-07-05T16:27:35Z")

</div>

I’m not sure if the following two threads are relevant (helpful) **but there may be something here:**

[https://forum.processing.org/two/discussion/8887/prevent-processing-from-opening-a-frame](https://forum.processing.org/two/discussion/8887/prevent-processing-from-opening-a-frame)

**or here:**

> [@Can you run a Processing sketch and hide the Canvas Window?](https://discourse.processing.org/t/can-you-run-a-processing-sketch-and-hide-the-canvas-window/18542):
>
> Hi everyone. I’ve seen a few posts on this topic, but none that seem to answer what I am looking for. I am trying to use Processing in a live, VJ type situation, with the a Processing sketch reacting to OSC messages, and seamlessly switch from one Processing sketch to another. After a lot of homework and searching around, I found I can send the visual output of my sketch to VDMX using Syphon. And I can fade in another image in VDMX while I switch sketches in Processing. Here is my question: B…

Plus there’s this (which you’re probably aware of 🙂) if you want to move over to p5js. I include only for the purpose of others searching the same question at some future date:

> **[reference | p5.js](https://p5js.org/reference/#/p5/noCanvas)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

🤓

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [July 7, 2021, 11:36am UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/10 "2021-07-07T11:36:46Z")

</div>

Thank you for showing me that! I was messing around with it and made a simple project!  
I call it: “quasi console”! It functions like a non erasable text software with commands.

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c831d3414f773c7f3bb1dbb640fc260730afa905.png)

---

<div class="post-metadata">

### Author: ![pirela](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pirela](https://discourse.processing.org/u/pirela)
#### Post date: [July 9, 2021, 6:30am UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/11 "2021-07-09T06:30:14Z")

</div>

You are looking for a REPL (Read Eval Print Loop) feature. A lot or languages have it (Make a search).  
Have a look on the java9 REPL for your project .

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [July 9, 2021, 6:43am UTC](https://discourse.processing.org/t/open-console-instead-of-window/31040/12 "2021-07-09T06:43:32Z")

</div>

here is a solution for drawing whilst hiding the sketch window. This seems to create a new thread so I don’t know what limitations it may have.

```auto
import java.awt.Frame;
import processing.awt.PSurfaceAWT;
import processing.awt.PSurfaceAWT.SmoothCanvas;
PWindow win1,win2;

public void settings() {
  size(1400, 700);
  
};

void setup() { 
  win1 = new PWindow(width/2-5,0,width/2,height,"first Window");
  win2 = new PWindow(0,0,width/2,height,"Second Window");
  surface.setLocation(-5, 0);
};

void draw() {
  background(255, 0, 0);
  fill(255);
  rect(mouseX, mouseY, frameCount, 10);
  if(win2.canvas!=null)image(win2.canvas,width/2,0);
  if(win1.canvas!=null)image(win1.canvas,0,0);
};

void mousePressed() {
  println("mousePressed in primary window");
};  

```

```auto
class PWindow extends PApplet {
  int x,y,w,h;
  boolean setLocation,setTitle,makeResizable;
  String title;
  PImage canvas;
  color bg = color(random(255),random(255),random(255));
  
  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
    
  };
  
  PWindow(int x_,int y_) {
    super();
    x = x_;
    y = y_;
    setLocation = true;
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
    
  };
  
  PWindow(int x_,int y_,int ww, int hh) {
    super();
    x = x_;
    y = y_;
    w = ww;
    h = hh;
    
    setLocation = true;
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  };
  
  PWindow(int x_,int y_,int ww,int hh,String s) {
    super();
    x = x_;
    y = y_;
    w = ww;
    h = hh;
    setLocation = true;
    title = s;
    setTitle = true;
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
    
  };
  
  PWindow(int x_,int y_, String s, boolean k) {
    super();
    x = x_;
    y = y_;
    setLocation = true;
    title = s;
    setTitle = true;
    makeResizable = true;
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  };
  

  void settings() {
    if(w>0&&h>0)size(w, h);
    else size(500, 200);
  };

  void setup() {
    background(150);
    if(setLocation)surface.setLocation(x, y);
    if(setTitle)surface.setTitle(title);
    if(makeResizable)surface.setResizable(true);
    surface.setVisible (false);
  };

  void draw() {
    background(bg);
    ellipse(random(width), random(height), random(50), random(50));
    fill(255);
    text(frameRate,20,20);
    canvas = get();
  };

  void mousePressed() {
    println("mousePressed in secondary window");
    closeWindow();
  };
  
  void closeWindow(){
    Frame frame = ( (SmoothCanvas) ((PSurfaceAWT)surface).getNative()).getFrame();
    frame.dispose();
  };
};

```

I’m dont know if there is a more efficient alternative to the `canvas.get()` method.
