![]() |
|
[Java] How would I make an executable jar open a command prompt window? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] How would I make an executable jar open a command prompt window? (/showthread.php?tid=3893771) |
How would I make an executable jar open a command prompt window? - ImportUsername - Nov 28, 2013 I have my program in an executable jar, which has output from System.out.println(). However unless someone goes into cmd/terminal and runs it, the output doesn't appear anywhere, even though it's running (making it a lot more difficult to close as well). I was wondering how I could make it open a command prompt window on startup so that the output could always appear, regardless to if it were run in cmd/terminal or if it were just double-clicked. * - кovu - Nov 28, 2013 As an alternative to that, you could make it open a JFrame with an info field that you use instead of System.out.println. * - ImportUsername - Nov 28, 2013 (Nov 28, 2013 09:45 AM)Rainfur Wrote: As an alternative to that, you could make it open a JFrame with an info field that you use instead of System.out.println. That sounds like it could work as well. How would I go about doing that? * - 3 Kings - Nov 28, 2013 make a batch file: @echo off java -jar jarFile.jar pause put this in the notepad and save it as: run.bat Then run it with the jar file located locally * - кovu - Nov 28, 2013 (Nov 28, 2013 09:46 AM)ImportUsername Wrote: That sounds like it could work as well. How would I go about doing that? Make a JFrame, add a label or text field. Then, just .add() to it the system.out.printlns. * - Manthe - Nov 28, 2013 (Nov 28, 2013 10:32 AM)3 Kings Wrote: make a batch file: Thats missing the whole point of having an executable jar. * - Sparta. - Nov 29, 2013 (Nov 28, 2013 08:36 PM)tango_beast Wrote: Thats missing the whole point of having an executable jar. Not really. You are using a bat file to open the executable. That's like saying "using the mouse to double-click and execute it" is missing the whole point of having an executable jar. * - Cyllon - Nov 29, 2013 Runtime.getRuntime().exec("cmd /c start"); I also think you can add "echo" and the text you want, if you place it behind start in the runtime command[/quote] I think its that 🤝 |