processbuilder

How to use ProcessBuilder to continually interact with a CLI program

淺唱寂寞╮ 提交于 2020-01-30 13:15:42
问题 I use a CLI program regularly which is accessed through a docker container. Once I enter the container, I can start using my CLI program in question. The issue I'm having is I want to continue to interact with the same command line instance. Basically I'm trying to create a GUI program that will run "on top" of a CLI program. I just don't know how to keep sending commands to the same CLI instance: List<String> command = new ArrayList<String>(); command.add("cmd.exe" ); command.add("/c");

How to use ProcessBuilder to continually interact with a CLI program

懵懂的女人 提交于 2020-01-30 13:15:31
问题 I use a CLI program regularly which is accessed through a docker container. Once I enter the container, I can start using my CLI program in question. The issue I'm having is I want to continue to interact with the same command line instance. Basically I'm trying to create a GUI program that will run "on top" of a CLI program. I just don't know how to keep sending commands to the same CLI instance: List<String> command = new ArrayList<String>(); command.add("cmd.exe" ); command.add("/c");

Java: Can't execute external exe with arguments

时光毁灭记忆、已成空白 提交于 2020-01-30 07:56:05
问题 I’m trying to run an external program with arguments. The program can take different types of arguments, for instance avl tip.avl or avl < test.ops I can get avl tip.avl running through try { String[] list = {"avl", "test_0.avl"}; ProcessBuilder pb = new ProcessBuilder(list); pb.command(list); final Process p = pb.start(); BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); String line; while ((line = br.readLine()) != null) { System.out.println(line); } }

Setting a java ProcessBuilder environment with a bash script

点点圈 提交于 2020-01-24 00:39:27
问题 I've been using ProcessBuilder to successfully invoke a process with various environment variables using env.put("VAR","value") . Now I'd like to source some bash scripts to set a whole bunch of environment variables that are not predetermined within java. Anyone know of an easy way to do this? 回答1: bash supports the environment variable BASH_ENV on startup. Set the variable to your script and its contents will be sourced before execution. See bash(1) for details. 回答2: If your "batch scripts"

GWT + ProcessBuilder

廉价感情. 提交于 2020-01-22 02:41:06
问题 Is it possible to use ProcessBuilder with GWT? When I declare an instance of a new ProcessBuilder, I get: java.lang.ProcessBuilder is not supported by Google App Engine's Java runtime environment 回答1: Your question is about GWT supporting ProcessBuilder, but the error you get is from Google App Engine and not GWT related. If you are using ProcessBuilder from a GWT RPC method you shouldn't have any problems. However, you are using Google App Engine as your application server. Google App Engine

Run processbuilder and get in and output

≡放荡痞女 提交于 2020-01-17 04:33:05
问题 I'm trying to get my program to launch Enchanter to SSH into my server, but can't seem to figure out how to get in and output to go to stdin and stdout , or anywhere for that matter. I just get a blank output window in Netbeans. How to I get the Jar to run, and get input/output? public class openShell { public void openShell() throws IOException { String line; Scanner scan = new Scanner(System.in); ProcessBuilder builder = new ProcessBuilder ("C:\\Program Files\\Java\\lib\\enchanter-beanshell

ProcessBuilder won't run with arguments [duplicate]

家住魔仙堡 提交于 2020-01-15 20:16:09
问题 This question already has answers here : Execute with parameters (2 answers) Closed 6 years ago . I am trying to run "java -version" using ProcessBuilder: processBuilder = new ProcessBuilder("java -version"); process = processBuilder.start(); However I get an error: java.io.IOException: Cannot run program "java -version": CreateProcess error=2, The system cannot find the file specified When I remove the "-version" and do: processBuilder = new ProcessBuilder("java"); process = processBuilder

Running Powershell from Java

不打扰是莪最后的温柔 提交于 2020-01-15 08:11:28
问题 I am currently trying to see if I can run a program shortcut in windows (.lnk) file, from powershell, within Java. I know there are better tools to use, and that I should just interact directly with the .exe, but please humor me, this is for testing purposes. So essentially, I need to run the .lnk file, via powershell from java. The main predicament I am currently having is that the command which should work from within powershell "start \"C:/Adobe Reader X.lnk\"" In the IDE this will run

How to execute SQL file from CMD prompt using Java ProcessBuilder

为君一笑 提交于 2020-01-14 19:15:44
问题 I have written a java program using ProcessBuilder to launch CMD prompt & connect SQLPLUS to execute some SQL files. public class OracleConnect { public static void main(String[] args) throws IOException { String[] cmd = new String[] { "sqlplus", "<USER>/<PASSWORD>@<INSTANCE>" }; ProcessBuilder builder = new ProcessBuilder(cmd); Process process = builder.start(); BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedWriter bw = new BufferedWriter(new

How to execute SQL file from CMD prompt using Java ProcessBuilder

感情迁移 提交于 2020-01-14 19:12:36
问题 I have written a java program using ProcessBuilder to launch CMD prompt & connect SQLPLUS to execute some SQL files. public class OracleConnect { public static void main(String[] args) throws IOException { String[] cmd = new String[] { "sqlplus", "<USER>/<PASSWORD>@<INSTANCE>" }; ProcessBuilder builder = new ProcessBuilder(cmd); Process process = builder.start(); BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedWriter bw = new BufferedWriter(new