0

I'm trying to start another program I've written with the program I'm currently writing. Right now I am trying to do so by starting the batch file I created for it, but that doesn't seem to work, but I don't know why.

Runtime.getRuntime().exec( "cmd F/AKS/Abgaben/Aufgabenblatt1/allesRichtig/runTest1.bat");

Am I doing something wrong with the command? Even though it does seem to find the bat file.

0

1 Answer 1

0

Try to use:

Runtime.getRuntime().exec("cmd /c start F:\\AKS\\Abgaben\\Aufgabenblatt1\\allesRichtig\\runTest1.bat");

Additional code snippet:
https://stackoverflow.com/a/7952126/462347

Sign up to request clarification or add additional context in comments.

8 Comments

If i try that, my cmd opens and says it cant find the file which the batch-file is supposed to start. But if i start the batch file normally through the explorer it works just fine.
@MaryLu, I'd try to save you bat in the same folder as your Java project and try to execute it in order to assure that there is no issue with the permissions. Also, please, check that any third part software (e.g. antivirus) doesn't block execution of your code. Where your Java-code is located? Disc «C:\» or «F:\»?
Which Projekt do you mean? The one I'm working on right now? beacause right now the Batch file is in the folder, where the package, of the class i'm trying to start, is located. Whenever I try to put it somewhere else i cant get the Batch file to start. i guess i'm giving it a wrong comand in that case. Right now it just says: java.exe aufgabenblatt01_Lux_MarieLuise_11099037/AKSTestTask1 and everything is located on F:\
Which path to your BAT do you use? F/AKS/Abgaben/Aufgabenblatt1/allesRichtig/runTest1.bat or F:\\AKS\\Abgaben\\Aufgabenblatt1\\allesRichtig\\runTest1.bat?
@MaryLu, try edit your BAT as it described below: stackoverflow.com/questions/12096016/java-cant-find-main-class
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.