0

I am creating a Java swing GUI, which takes few parameters from user (through text fields) and stores them in a string called finalstring. This string is basically a command, which runs an ".exe" file with few parameters. Now i want to create a batch file(start.bat on my desktop), in which i want to copy this string. Finally i want to execute this batch file. Along with the execution, i also want to store the output of this batch file. Also, the batch file executes certain process, which i want to link with progress bar, is this possible?(process running in batch file, to be linked to java swing's progress bar?).

I did all above things using python and tkinter as GUI, but during the storage of output of batch file, my tkinter gui used to hang(not responding), so i am switching to java swings GUI. I searched most of the online threads, but nothing is going in my head(created few java programs also, but the batch file is not being created), so i want help, i appreciate your effort to go through this thread.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
Niyojan
  • 544
  • 1
  • 6
  • 23
  • 1
    Sounds like a horrible design. And I would even say that Java is not the right language for that. Try .NET, it has better connections to the OS. – Sebastian Feb 27 '13 at 10:18
  • *"is this possible?"* - The way you described, I wouldn't think so. If you were determined to run this from Java (which would give you access to a progress bar), then yes, it would require some decent library code (executing a command, getting the output, etc), but it would be doable. – MadProgrammer Feb 27 '13 at 10:21
  • Its ok if i dont connect the output stream to progress bar, but atleast mention the code to create new batch file with "finalstring" in it..Thanks – Niyojan Feb 27 '13 at 10:27

1 Answers1

1

You can execute your batch using ProcessBuilder, as shown here. You can append() lines from the combined output stream to a JTextArea, as shown here.

I'm not sure you can usefully display progress in a JProgressBar without knowing more about the granularity of the process.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045