java run cmd commands
NickName:louis Ask DateTime:2013-11-15T17:00:42

java run cmd commands

I have some problem about run windows cmd ,when I run my code on GEL or some java tool,it works,but it run error that windows can't find "pscp".However,I export execute jar from eclipse and java -jar ..It works!! I set pscp path first, so i can type pscp commend on cmd.

String file="test5.pdf";

String Ip="140.118.175.196";
String commend="cmd.exe /c start pscp.exe d://"+file+" admin@"+Ip+":/home/admin/test";

Process ee = Runtime.getRuntime().exec(commend);

What happen? Thanks.

Copyright Notice:Content Author:「louis」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19997130/java-run-cmd-commands

More about “java run cmd commands” related questions

Run multiple cmd commands from java

I want to run multiple cmd commands succesively from java code one after the other. I want to use this one command line application which creates ssh connection and I want to run multiple commands

Show Detail

Run cmd commands through Java

I found several code snippets for running cmd commands through a Java class, but I wasn't able to understand it. This is code for opening the cmd public void excCommand(String new_dir){ Runt...

Show Detail

Run cmd commands through Java

I found several code snippets for running cmd commands through a Java class, but I wasn't able to understand it. This is code for opening the cmd public void excCommand(String new_dir){ Runt...

Show Detail

Run cmd commands through java processBuilder

I am trying to use ProcessBuild to run the cmd statement. ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/C", "start"); Process p = pb.start(); However, I can only open the cmd.exe I do no

Show Detail

Run cmd commands in the background through java

I am creating a GUI in java that requires a set of commands to be run through the command line one after the other in the background after the user selects a file and clicks a button in the GUI. The

Show Detail

How to run multiple cmd commands through Java?

I have a simple GUI which selects an executable and a batch file. Clicking "run" should launch a command line instance, then run the executable given the selected batch. However, hiccups ...

Show Detail

java run cmd commands

I have some problem about run windows cmd ,when I run my code on GEL or some java tool,it works,but it run error that windows can't find "pscp".However,I export execute jar from eclipse and java -j...

Show Detail

Run class file using cmd commands

How can I run a class file using a java program with cmd commands?

Show Detail

How to invoke cmd commands in from a Java program in Windows?

I want to create an application which can compile and run external programs. For this I need to run compiler commands from the command prompt (commands like javac and gcc). I tried the approach given

Show Detail

With Java, run multiple commands in the same cmd.exe window

I'm developing a Java application that will be run on a Windows computer occasionally. At some point I need to run a Cygwin prompt and performs some commands in it. I've found a topic where the Ru...

Show Detail