-2

Java newbie here. I recently started making a text-based game in Java through my Eclipse IDE, and so I wanted to make a the program a little better. Every time I run the program, it just runs in the "Run" window in the bottom left of the Java IDE. Instead of this, I want a new windows opening, displaying the text and allowing the user to enter input via the window. How can I set this up? Thanks in advance.

  • Maybe look at a `JOptionPane`? https://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html – GBlodgett Sep 23 '18 at 19:23
  • Possible duplicate of https://stackoverflow.com/questions/34140373/how-to-make-eclipse-run-my-program-in-a-terminal – Harald Gliebe Sep 23 '18 at 19:23
  • 1
    Then you need different IDE, like TextPad. It wull allow java programs to run on command prompt window. – Joe Vanjik Sep 23 '18 at 19:24
  • Do you want to create a GUI and run the program as a stand-alone GUI program? If so, then first make sure that your code is "clean", meaning that you have well constructed OOP-compliant classes, ones with instance fields, methods, constructors and what-not, and only then construct a GUI "view" to display the state of your non-GUI model classes. You can use Swing as noted above or better the newer JavaFX GUI libraries for this. – Hovercraft Full Of Eels Sep 23 '18 at 19:24
  • 3
    That it runs " in the bottom left of the IDE" is just an Eclipse thing. When you run the program directly from its java classes/jar it will work in its own windows console window. – leonbloy Sep 23 '18 at 19:29

1 Answers1

-1

There would be very limited options here, such as using a process builder and then reading the output stream every time you submit a command. But that is a very lengthy process and would probably double or triple the size of your code.

The option that I would recommend is to export your program as an executable jar file, (if using eclipse,) or similar on another IDE and then running it in command prompt or the terminal with Java Runtime.

That would be a simple process taking less than 5 minutes to do, plus this would allow you to see how your program works outside of the IDE.