runtime.exec

Runtime.getRuntime failed to get output same time but later

你。 提交于 2019-12-11 10:44:15
问题 I'm currently making firefox addon development GUI tool using Java. However I am stuck when trying to get output of a .bat file. When I run .bat file using java I can see the output, but there are 3 commands written in the bat file. When first command executes I can get the output simultaneously. But when it execute second command output not coming. And when .bat file exist I get all the output which didn't come simultaneously. I'm getting output immediately when it execute: call "C:\mozilla

How to open file in Microsoft Word on Mac OS X from within Java?

谁说胖子不能爱 提交于 2019-12-11 08:35:29
问题 I am trying to open *.docx files programmatically from Java on Mac OS X. For Windows and Linux I already got it working with the following methods: Windows: Runtime.getRuntime().exec(new String[] {"C:\Program Files\Microsoft Office\Office15\WINWORD.EXE", "document.docx"}); Linux: Runtime.getRuntime().exec(new String[] {"/bin/sh", "-c", "/usr/bin/libreoffice", "document.docx"}); How does it work with Mac OS X ? My Microsoft Office installation is at the following location: /Applications

How do I execute a sequence of related console commands?

与世无争的帅哥 提交于 2019-12-11 08:15:02
问题 I'm currently working on a project where a client receives shell/console commands from a server, and must execute them. How do I get Java to run these commands from within either a shell or a command prompt? I'm hoping to be able to disregard the platform type - and not have to specify shell or command prompt - but if I can't, then that's okay. I must be able to send a sequence of related commands, not just one command. This means that the shell/prompt cannot exit or close between commands.

How to get the value that is passed to Runtime.getRuntime.exit(value) in a JUnit test case

邮差的信 提交于 2019-12-11 08:13:10
问题 I have to write a Test case in JUnit for a Class lets call it C1 which internally calls Runtime.getRuntime.exit(somevalue) . The class C1 has a main method which accepts some arguments and the creates a CommandLine and then depending on the passed arguments does the specific tasks. Now all tasks after executing call a Runtime.getRuntime.exit(somevalue) . The somevalue defines whether the task was executed successfully (means somevalue is 0) or had errors (means somevalue is 1). In the JUnit

Java exec use input redirect

。_饼干妹妹 提交于 2019-12-11 07:49:54
问题 String cmd=" D:/James/1 ASU/REU/senna-v3.0/senna/senna-win32.exe -posvbs < \"D:/James/1 ASU/REU/senna-v3.0/senna/tmp.tmp\""; Process p2 = Runtime.getRuntime().exec(cmd); I want to run an application and push input into it from a text file. I tried the above and the application ran, but the application complained and says "<" is not a valid command line argument. invalid argument: < D:/James/1 ASU/REU/senna-v3.0/senna/tmp.tmp SENNA Tagger (POS - CHK - NER - SRL) (c) Ronan Collobert 2009 How

trouble with ProcessBuilder

混江龙づ霸主 提交于 2019-12-11 05:41:36
问题 // following code works fine n open notepad... class demo { public static void main(String args[]) { try{ ProcessBuilder pb=new ProcessBuilder("notepad"); pb.start(); }catch(Exception e) {System.out.print(e);} } } //however the above code throws an exception when any other system program is executed class demo { public static void main(String args[]) { try{ ProcessBuilder pb=new ProcessBuilder("calculator"); pb.start(); }catch(Exception e) {System.out.print(e);} } } the above program throws

Array of methods not working ionic 2

不羁岁月 提交于 2019-12-11 05:36:53
问题 I'm working on ionic 2. I've created a menu for my page and an array of contents for menu. menuItems: Array<{title: string, icon: string, method: any}> And added elements. this.menuItems = [ {title: "Edit Account", icon: "create", method: "editAcount()"}, {title: "Change Password", icon: "create", method: "changePassword()"}, {title: "LogOut", icon: "log-out", method: "logOut()"}, ]; And I'm calling methods at run-time. <ion-item *ngFor = "let item of menuItems" menuClose (click) = "item

Java - Exec console

ぃ、小莉子 提交于 2019-12-11 04:53:51
问题 I want to create a full cross-plateform console in Java. The problem I have is when I use the cd command, the path is reset. For example, if I do cd bin , then cd ../ , I will execute the first one from the directory of my app and the second one exactly from the same directory. If I want to go to a specific folder and execute a program I have to do something like that: cd C:\mydir & cd bin & start.exe What I want to do is to split this cmd in different parts: cd C:\mydir then cd bin then

Run .exe packaged in .jar

女生的网名这么多〃 提交于 2019-12-11 04:24:01
问题 I am trying to merge 2 programs I have made to one .jar file. One program is a .jar written in java and the second one is an .exe written in c++. I put both files to the new .jar, wrote this code but it didn't work. When this code was exported to .jar and executed neither of 2 files ran and I got error "no main manifest attribute, in merged.jar" in cmd. Though it worked perfectly when run in eclipse. public class main { public static void main(String[] args) { try { Runtime.getRuntime().exec(

Runtime Exec stop unexpectedly

天大地大妈咪最大 提交于 2019-12-11 02:13:02
问题 I have a little executable program in C that produce a lot of output to a file. When I call this program with Runtime, like this: Runtime r = Runtime.getRuntime(); Process p = null; p = r.exec("./my_program -in input.file -out output.file", null, new File(System.getProperty("java.io.tmpdir"))); When the program produce low output everything is ok, but when I call "*my_program*" with a large input it will produce a large quantity of output to the output.file, but in this case my program in