runtime.exec

Problem with Runtime.exec and Android

本小妞迷上赌 提交于 2019-12-18 09:27:52
问题 I have an issue when I'm using Runtime.exec with my Android device and just can't figure out why it happens... Here is an example of the tests I did : public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Runtime runtime = Runtime.getRuntime(); for(int i=0; i< 20; i++){ Log.d("TESTEXEC", "EXEC N°"+i+" : BEGIN"); try { Process process = runtime.exec("/system/bin/ps"); process

Trying to execute a Java jar with Runtime.getRuntime().exec()

随声附和 提交于 2019-12-18 07:04:58
问题 In the project I am working on, I need to execute a script that I have in a resources folder -- in the class path. I am simply testing the final script functionality, since I am on Windows, I needed a way to output a file to STDIN so I created a simple cat.jar program to clone unixs cat command. So when I do "java -jar cat.jar someFile.txt" it will output the file to stdout. I'm sure there are different ways of doing what I did. Anyways, I want to run that JAR from my main java program. I am

ProcessBuilder vs Runtime.exec()

只谈情不闲聊 提交于 2019-12-18 04:48:10
问题 I'm trying to create a frontend app in Java to handle batch SVG conversions using Inkscape's command line feature. I'm taking and updating the code from https://sourceforge.net/projects/conversionsvg/. The way the original developer handled calling Inkscape by Runtime.getRuntime().exec(String) . The issue I'm running into is some inconsistencies between using methodA and methodB. I created a simple java test project to demonstrate the different actions being performed. CallerTest.java package

How do I get the bash command exit code from a Process run from within Java?

给你一囗甜甜゛ 提交于 2019-12-17 22:59:15
问题 I have a program which is: import java.io.*; import java.util.*; public class ExecBashCommand { public static void main(String args[]) throws IOException { if (args.length <= 0) { System.err.println("Need command to run"); System.exit(-1); } Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec("./nv0914 < nv0914.challenge"); Process process1 = runtime.exec("echo ${?}"); InputStream is = process1.getInputStream(); InputStreamReader isr = new InputStreamReader(is);

Taking thread dumps in production

只愿长相守 提交于 2019-12-17 21:56:22
问题 I am analyzing the differences between approaches for taking thread dumps. Below are the couple of them I am researching on Defining a jmx bean which triggers jstack through Runtime.exec() on clicking a declared bean operation. Daemon thread executing "ManagementFactory.getThreadMXBean().dumpAllThreads(true, true)" repeatedly after a predefined interval. Comparing the thread dump outputs between the two, I see the below disadvantages with approach 2 Thread dumps logged with approach 2 cannot

Efficient execution and output stream redirection of process spawned with Runtime.exec()

偶尔善良 提交于 2019-12-17 19:19:24
问题 I have a script which executes a program several times, producing about 350 lines of output to both STDERR and STDOUT. Now, I need to execute the script in Java, thereby printing the output streams to their original destinations. So, basically, I execute the script from inside a Java class, maintaining the original behavior for the user. The way I do this is inspired from suggestions like Reading streams from java Runtime.exec and, functionally, works fine. Process p = Runtime.getRuntime()

use java-ffmpeg wrapper, or simply use java runtime to execute ffmpeg?

女生的网名这么多〃 提交于 2019-12-17 06:27:21
问题 I'm pretty new to Java, need to write a program that listen to video conversion instructions and convert the video once an new instruction arrives (instructions is stored in Amazon SQS, but it's irrelevant to my question) I'm facing a choice, either use Java RunTime to exec 'ffmpeg' conversion (like from command line), or I can use a ffmpeg wrapper written inJava http://fmj-sf.net/ffmpeg-java/getting_started.php I'd much prefer using Java Runtime to exec ffmpeg directly, and avoid using java

Redirection with Runtime.getRuntime().exec() doesn't work

只谈情不闲聊 提交于 2019-12-17 05:12:07
问题 I need to execute a command from a program. The command line is ok, I tried it in the terminal, but it doesn't work in the program. I add a copy from my code: File dir = new File("videos"); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory System.out.print("No existe el directorio\n"); } else { for (int i=0; i<children.length; i++) { // Get filename of file or directory String filename = children[i]; //Recojo el momento exacto System

How to solve “java.io.IOException: error=12, Cannot allocate memory” calling Runtime#exec()?

冷暖自知 提交于 2019-12-17 02:34:13
问题 On my system I can't run a simple Java application that start a process. I don't know how to solve. Could you give me some hints how to solve? The program is: [root@newton sisma-acquirer]# cat prova.java import java.io.IOException; public class prova { public static void main(String[] args) throws IOException { Runtime.getRuntime().exec("ls"); } } The result is: [root@newton sisma-acquirer]# javac prova.java && java -cp . prova Exception in thread "main" java.io.IOException: Cannot run

How to solve “java.io.IOException: error=12, Cannot allocate memory” calling Runtime#exec()?

岁酱吖の 提交于 2019-12-17 02:33:55
问题 On my system I can't run a simple Java application that start a process. I don't know how to solve. Could you give me some hints how to solve? The program is: [root@newton sisma-acquirer]# cat prova.java import java.io.IOException; public class prova { public static void main(String[] args) throws IOException { Runtime.getRuntime().exec("ls"); } } The result is: [root@newton sisma-acquirer]# javac prova.java && java -cp . prova Exception in thread "main" java.io.IOException: Cannot run