Reputation: 21
I'm building a library for making command line games as a fun project, and while I have most of the code done, I've hit a roadblock with end-user viewing. What I would like is when the application is jpackaged, the user runs it, and it opens a terminal window. While I have opened a window using Runtime.getRuntime().exec("/usr/bin/open -a Terminal");
, I was wondering how I could make it so - using the process returned from .exec(...)
- that window is the one which is running the application. Example; thats the window where System.out.println
prints to.
Is this even possible, or should I be doing it a different way.
Any help is appreciated.
Upvotes: 1
Views: 127
Reputation: 294
There are 2 methods that I know about.
Method 1 : If you've coded the game and made it a JAR. You can type this in CMD to print the game in CMD.EXE
java -jar "LocationOfJar"
like java -jar C:/Users/TOP10/Desktop/Game.jar
or if the command is in the same folder as the jar.. java -jar Game.jar
Method 2 : Create an OutputStream
and connect it to a JFrame
with a JTextField
.
Create an OutputStream
that streams outputs to a Text field in a window that your library should show.
More Info : how to visualize console java in JFrame/JPanel
Upvotes: 1