Questions tagged [runtime.exec]

The Runtime.exec() method allows Java apps. to create a new OS Process.

The Runtime.exec(...) method (which has 6 overloaded variants) allows Java apps. to create a new system (represented in Java as a Process).

There are common mistakes made when creating new processes - as detailed in When Runtime.exec() won't. The article is the first thing to check if a process fails. Implement all the tips, and even if doing so does not make the process work, it will provide much more detailed information on why it failed.

The ProcessBuilder class introduced in Java 1.5 makes it easier to create and use a process correctly. For example, the redirectErrorStream(boolean) convenience method will merge the System.out & System.err streams, which allows both streams to be consumed in one Thread.

881 questions
-1
votes
1 answer

Exception in thread "main" : unresolved compilation probl*m

Getting error "Exeption in thread "main" java.lang.Error 'Unresolved compilation problem': at ClassName.main(ProjectName.java:7) this is just a test program to see how runtimes work public static void main(String[] args) Runtime runtime =…
sixten
  • 21
  • 1
  • 5
-1
votes
1 answer

How to execute a python file with some arguments in java

String command: python FileName.py userName pswd Process p = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line =…
Shakir
  • 123
  • 1
  • 4
  • 14
-1
votes
1 answer

I am trying to embed a program in my program, can I?

I want to run a program (In this example, Notepad) in another program that I am writing. I want Notepad to be confined to a box inside my program that I can define, let's say 500 x 500. Then I can add my normal window components like text and…
-1
votes
1 answer

Call external script to execute

In my project i have imported perl scripts . so my project now contains: A class file consisting of java code to execute a task and A perl script , which need to be called in the above (1.) class. The main operation i need to achieve is : i want…
SomeOne
  • 93
  • 8
-1
votes
1 answer

Runtime exec command working when when run from terminal but not eclipse

I'm trying to use tesseract to do OCR on an image in java. I realize there are wrappers like Tess4J that provide a bunch more functionality and stuff, but I've been struggling to get it set up properly. Simply running a one-line command with Runtime…
sc8ing
  • 369
  • 1
  • 3
  • 9
-1
votes
1 answer

Running adb commands like dmesg and logcat in my app in real time

Here's what I'm trying to accomplish: I want to be able to show dmesg logs and logcat output in an app I'm writing. I know that I'm supposed to use Runtime.getRuntime().exec(), however other than that, I'm pretty lost. I tried to find some examples,…
Andi Jay
  • 5,882
  • 13
  • 51
  • 61
-1
votes
1 answer

Could not load main class when compiled and executed with Runtime.exec()

I have the following code to run three executions : public static void main(String[] args) throws InterruptedException, IOException { String filepath1 = "cmd /c gradlew jmhJar"; String…
nt fury
  • 39
  • 1
  • 9
-1
votes
2 answers

Could not find or load default class

I try to using Runtime but have some problem. I want to use Runtime.exec("java -cp"). One is jar file, another is class file. Class file is refer to jar file but not included. Below is my code Runtime rt = Runtime.getRuntime(); Process proc =…
ho9
  • 42
  • 6
-1
votes
2 answers

Runtime.getRuntime() restart mac Java IM

My os is MAC OS 10.11.3. I using Spark as our IM(Instant messaging),but when the IM log out,IM give an error,said: java.io.IOException: Cannot run program "open": error=2, No such file or directory . But when Eclipse runs it, it worked well,and…
-1
votes
1 answer

Unable to execute a particular shell command command using Java - permissions working correctly

I am having trouble executing a shell command using Java. I am calling 4 commands which are supposed to run the sourceanalyzer executable from within the runFortifyScan method, and populate the fpr and pdf folders that I have created. import…
tubby
  • 2,074
  • 3
  • 33
  • 55
-1
votes
1 answer

java code to export oracle 11g dump file to the database

I have shell script for creating dump file of oracle 11g database. I want to run it through java code, I did find any working solutions on the web. Can anyone help me on this. Script expdp test/test@localhost:1521/ORCL DIRECTORY=orcl_full2…
Shamim Ahmad
  • 808
  • 3
  • 22
  • 40
-1
votes
1 answer

Running Multiple commands on same Bash via Java Runtime or ProcessBuilder

I want to run the following commands:- # su - username $ ssh-keygen -t rsa enter 3 time to pass null to ssh-keygen options then $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys $ chmod 0600 ~/.ssh/authorized_keys $ tar xzf tarpath $ mv…
Ap00rv
  • 128
  • 1
  • 11
-1
votes
1 answer

jar compile Runtime.getRuntime.exec() full directory in jar

Just for fun I'm making a little Java project file to keep on my dropbox to compile java for me without an ide easier than typing all those pesky command line arguments myself. Right now I am just having one small problem... First here's my code…
parabolah
  • 65
  • 3
  • 11
-1
votes
1 answer

Unable to load main class using servlet

This code I had found on stackoverflow but the replies could not solve the problem. I'm creating a web based compiler where I take the java file name using the "name" string and the code using the "text" string. I'm compiling and executing the code…
-1
votes
1 answer

How to stop a command execution in java

Is there a way to stop a running process using java? I'm using this piece of code to run a command: Process process = Runtime.getRuntime().exec(String.format("cmd /c %s", command)); Afterwards, I need to end/stop/terminate it. Does anyone knows how…
lrente
  • 1,070
  • 1
  • 9
  • 27