This question already has answers here:
How do I run a batch file from my Java Application?
(12 answers)
Closed 7 years ago.
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.
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
Related
This question already has answers here:
How to get the current working directory in Java?
(26 answers)
Closed 2 years ago.
I have a java program and I want it to be able to print out its location on the computer. For example, if I were to place the program in the Downloads folder, and run it, it would print out the path to the file.
new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation()
.toURI()).getPath();
make sure to change the Myclass.class stuff
then system.out.println(File)
This question already has answers here:
Viewing contents of a .jar file [closed]
(31 answers)
Closed 4 years ago.
I would like to see which files are in my jar File.
I've found out that I need to use java -jar
on my CentOS VM. But how do I add the parameters tf.
At the end I have something like: java -jar "MyJarFile.jar" -tf.
When I do it like that the parameters are getting ignored..
You can use decompression software (.jar is just an archive).
This question already has answers here:
How to send data to COM PORT using JAVA? [duplicate]
(3 answers)
Closed 6 years ago.
I am making POS which have comport printer. I created one text file and I want to give to the printer. I know the cmd command(print data.txt /d:com2) but how to give this command to CMD using java program?
If you do not care about stdin/stdout, them just
Runtime.getRuntime().exec("print data.txt /d:com2").waitFor();
This question already has answers here:
How do I add a Java backend to an existing PHP site without adding a tomcat server for Java Bridge?
(4 answers)
Closed 9 years ago.
I have created a program but i need to get a java program to run a php script with some arguments and then get the php script to send some arguments to the Java program. I know this question has been asked a lot of times but it seems like the only answer i can get is that php can do this but java cant but there must be a way to do it. Right?
You can run PHP from the command line:
http://php.net/manual/en/features.commandline.php
This should enable your Java application to run it, and capture it's return values.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Any way to “reboot” the JVM?
Is there any option to restart currently executing .jar(a complete project),by code from inside that program
You can invoke using Runtime.getRuntime().exec()
java -jar yourJar.jar
and immediately you can invoke
System.exit(0);
So launching new instance and stopping current