I want to be able to run a separate jar file, and be able to display any output from its console, and be able to send input. I want to be able to create a console which will act like the console in windows 7, but look better.
Asked
Active
Viewed 60 times
2
-
2Your question is unclear. Do you want to know how to convert your application to a jar, or how to run a separate jar from your application? Please explain exactly what you want to do with it. – RealSkeptic Nov 30 '14 at 11:55
-
I think it's clear what the OP is after. He wants to run a "separate" (=external) jar in a console that looks better than the one provided by the system (windows 7). For this he needs to be able to handle I/O of the external process. – aioobe Nov 30 '14 at 12:05
2 Answers
1
You can use ProcessBuilder
to launch java -jar yourprogram.jar
as follows:
Process p = new ProcessBuilder("java", "-jar", "yourprogram.jar").start();
To deal with input / output of this process, you can follow this post:
0
After finishing your code , create jar file output (It depends on which IDEA you are working on)
then you can use java -jar JarFileName.jar
in order to run the jar file,
Note that JDK path should be defined in system environment to use java -jar
command,

Hana Bzh
- 2,212
- 3
- 18
- 38