Linked Questions
28 questions linked to/from How to execute command with parameters?
4
votes
4
answers
21k
views
Executing in java code an external program that takes arguments [duplicate]
Process p;
String line;
String path;
String[] params = new String [3];
params[0] = "D:\\prog.exe";
params[1] = picA+".jpg";
params[2] = picB+".jpg";
try
{
p = Runtime.getRuntime().exec(params);
...
2
votes
1
answer
3k
views
not able to execute rsync from java [duplicate]
Process p;
String cmd = "rsync --timeout=20 -v -r -E -e \"ssh -o StrictHostKeyChecking=no -i "
+ "/usr/local/my.pem\""
+ " root@<IP>:/usr/local/test/...
0
votes
2
answers
960
views
How to pass command-line argument from within a java program? [duplicate]
I want to use WordNet and its packages for which I am using wn.exe and need to pass "-n#" argument to it. How do I do it from within my java code which is running on the computer.
***Edit: I have a ...
0
votes
0
answers
1k
views
Executing openssl command using Java runtime [duplicate]
I am trying to execute the openssl command for encryption. I am trying to launch the openssl via java runtime.
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ...
2
votes
0
answers
692
views
Java can't run a shell script [duplicate]
I face a problem to run a ".sh" file from my Java code, which is written in bash. At this point, I am using the following command to run the script (which is in the local directory, and seems to be ...
-1
votes
2
answers
249
views
Linux commands not working properly from within Java program [duplicate]
I am working on a Spring based application in which we would like to use ImageMagick for some image processing. We have some commands, which I want to try out after text-processing(mainly splitting ...
18
votes
4
answers
17k
views
Java Runtime exec() fails to escape characters properly
This might already been answered before but that was regarding unicode and I don't think this is unicode (it's in ASCII so...).
When I execute this in my terminal there is no problem what so ever
...
9
votes
8
answers
22k
views
Escape whitespace in filepath
I am writing a small Java Application and I am having problems with a filepath.
I want to execute a batch file with
Runtime.getRuntime().exec("cmd /c start c:\program files\folder\file.bat");
But ...
2
votes
2
answers
17k
views
How to pass parameter to shell script in java program
i am trying to run this java code that calls the shell script on runtime.
when i run the script in terminal i am passing argument to script
code:
./test.sh argument1
java code:
public class ...
2
votes
5
answers
1k
views
How do I open a application with spaces in the name using Runtime.getRuntime().exec()?
So I am trying to make a universal app, and I am trying to make it have the ability to open applications. So, I figured out to make it open an application if it is one word, but with spaces, it never ...
4
votes
4
answers
5k
views
Executing a shell script with an empty argument from Java
I have bash script that takes in a couple of arguments tests then and runs a command as shown below
call script => /bin/bash myscript arg1 arg2 arg3 arg4
comm called => command -a arg1 -b arg2 -...
2
votes
1
answer
6k
views
Java Runtime.exec() arguments on Linux
Okay so here is the problem:
I have 3 classes MyClass1 and MyClass2 and ExecClass.
I go to my command prompt and do this:
$java MyClass1 -exec "java MyClass2 arg1 arg2"
which works perfectly.
Now in ...
2
votes
2
answers
3k
views
Java Runtime.getRuntime().exec on Windows error
I am trying to run this line of code:
Process p = Runtime.getRuntime().exec(new String[] {"nmap -sP 192.168.1.0/24", g});
The above gives this error:
Exception in thread "main" java.io.IOException: ...
0
votes
3
answers
4k
views
Running Unix Command in Java File
I was trying to run a unix command in java to overlook the double quotation mark in a parsed file:
for(int i = 0; i < numTables; i++){
try{
String command = "sed -e \'s/\"/\...
0
votes
1
answer
2k
views
CURL REST Command in java, header specified but still received 415 Unsupported Media Type
I am trying to send REST request by sending CURL command with Java Process Runtime with the code:
Process p = Runtime.getRuntime().exec("curl -i --user user_name:password -H \"Content-Type: ...