processbuilder

Java starting running command in new terminal (mac osx) - process builder not running osascript properly

穿精又带淫゛_ 提交于 2019-12-11 02:22:22
问题 I'm trying to create a new process in a new window. I'm following this example for the command Running a command in a new Mac OS X Terminal window (using Java Process builder). I printed out the resulting command and it works if I type it in manually, but it doesn't start the new window when I run it. Something as simple as osascript -e 'tell application "Terminal" to do script "java -jar test.jar"' doesn't bring anything up Sample code: try { ProcessBuilder pb = new ProcessBuilder("osascript

Process Builder java.io.IOException error=2

时间秒杀一切 提交于 2019-12-10 21:23:45
问题 I want to run a shell command from my Java application. I have compiled a software called "SRILM" and when I run it from shell everything is OK: ngram-count -text /home/istanbul/Desktop/snlp_hmm/model.txt -order 3 -lm hoho.lm However when I run it from my Java application: ProcessBuilder lmBuilder = new ProcessBuilder("ngram-count", "-text", modelPath, "-order", "3", "-lm", "hohom.lm"); lmBuilder.directory(new File("/home/istanbul/srilm/bin/i686-m64")); try { final Process lmProcess =

ProcessBuilder not executing Java class file properly

て烟熏妆下的殇ゞ 提交于 2019-12-10 19:28:22
问题 In a java file I am calling command line statement to execute another java file. This is what I am doing: List<String> paramsExecute = new ArrayList<String>(); paramsExecute.add("java"); paramsExecute.add("-cp"); paramsExecute.add("input\programs\User_K Program1"); paramsExecute.add("1 2 3"); ProcessBuilder builderExecute = new ProcessBuilder(paramsExecute); builderExecute.redirectOutput(new File(a.txt)); builderExecute.redirectError(new File(b.txt)); Execution of one of the Java files is

Java - Use Input and OutputStream of ProcessBuilder continuously

左心房为你撑大大i 提交于 2019-12-10 16:27:53
问题 I want to use an external tool while extracting some data (loop through lines). For that I first used Runtime.getRuntime().exec() to execute it. But then my extraction got really slow. So I am searching for a possibility to exec the external tool in each instance of the loop, using the same instance of shell. I found out, that I should use ProcessBuilder. But it's not working yet. Here is my code to test the execution (with input from the answers here in the forum already): public class

Start a process (using Runtime.exec / ProcessBuilder.start) with low priority

為{幸葍}努か 提交于 2019-12-10 15:32:23
问题 I need to start a CPU-intensive system process under low priority so that it doesn't slow down my server. How can I do this on Linux? This is similar to this question: Start a Java process at low priority using Runtime.exec / ProcessBuilder.start? except on Linux instead of Windows. It's OK if the process's priority is changed after the process is started (as long as there isn't much delay). 回答1: Run the command using /usr/bin/nice. For instance: $ /usr/bin/nice -n 10 somecommand arg1 arg2

gradle: Execute task “type:Exec” with many arguments with spaces

无人久伴 提交于 2019-12-10 13:22:38
问题 I have the gradle task that should create Websphere profile on Windows OS task createProfile(type:Exec) { def commandToExecute = new StringBuffer() def profile = 'AppSrv02' def wasHome = 'C:/IBM new/WebSphere/AppServer' def str = new LinkedList <String> (); str.add('cmd') str.add('/c') str.add(wasHome + '/bin/manageprofiles.bat') str.add('-create') str.add('-profileName') str.add(profile) //str.add('-templatePath') //str.add(wasHome + '/profileTemplates/default') println (str) commandLine str

Writing to Windows CMD from Java

允我心安 提交于 2019-12-10 11:56:25
问题 I'm trying to be able to input commands into the command prompt on Windows from Java. I use processBuilder, open the command prompt, and get the output stream, but when I try to write to that, nothing seems to happen. Do I need to include something else, or am I going about this all wrong? I know that I can pass arguments including commands into the command prompt when I initially start it, but my goal is to be able to open the window first , then interact with it second , not at the same

Why processBuilder in java hangs after 5 mins?

夙愿已清 提交于 2019-12-10 11:41:21
问题 I hava command line which process more than 5 mins. when I invoke command line with ProcessBuilder, it works the command completes the job with in 5 mins. Whereas the process hangs if it takes more than 5 mins and shows no improvement on process until I quit the process. p = new ProcessBuilder("myprogram","with","parameter").start(); p.waitFor(); Please let me know if you doesn't understand the above question? 回答1: The problem might be, that command "myprogram" produces some output, and you

Java ProcessBuilder showing console of started java application?

孤者浪人 提交于 2019-12-10 11:14:15
问题 I have a JAVA application that launches (using ProcessBuilder) another JAVA application like this: String val = "something"; ProcessBuilder processBuilder = new ProcessBuilder("java", "-classpath", dir, appName, val); Process p = processBuilder.start(); Now, this works fine, appName is launched with the parameter val and it runs and works ... great ... the problem is no Console Window appears ... appName does a LOT of outputting to the console and we need to see it ... how can I start the

Process builder output and error redirection

会有一股神秘感。 提交于 2019-12-10 10:55:06
问题 I am using ProcessBuilder to run an executable file from another directory. I'm also redirecting output and error to files in the local directory. But strangely my error file shows the output of the executable and the output file is blank. I am not sure what is going on, can someone please shed some light on my situation. My code: File outputFile = new File("outputLog.txt"); File errorFile = new File("ErrLog.txt"); List<String> command = Arrays.asList("c:\\dataloader\\TestDataLoader.exe", "-h