runtime.exec

in x64 Windows is there a way to run a Runtime.exec() process avoiding 'Registry redirection'

Our app runs in jvm 32 bit, even when in windows x64. Now, at some point, I need to access some registry values, for example HKEY_LOCAL_MACHINE/SOFTWARE/mycomp. I do this by executing cmd /C reg query HKEY_LOCAL_MACHINE\SOFTWARE\mycop from Runtime.exec() and parsing the output. This works fine when running on windows 32b, the probl...

design for a wrapper around command-line utilities

im trying to come up with a design for a wrapper for use when invoking command line utilities in java. the trouble with runtime.exec() is that you need to keep reading from the process' out and err streams or it hangs when it fills its buffers. this has led me to the following design: public class CommandLineInterface { private fina...

how to redirect stdin to java Runtime.exec ?

I want to execute some sql scripts using Java's Runtime.exec method. I intend to invoke mysql.exe / mysql.sh and redirect the script file to this process. From the command prompt I can run the command <mysqInstallDir\/bin\mysql.exe -u <userName> -p <password> < scripts\create_tables.sql I can invoke mysql.exe using Runtime.exec but ...

crude Runtime.exec to call java -cp not working in linux

I'm using a java process to spawn many other java processes using Runtime.exec(cmd) where cmd is like the following: java -cp "MyJar.jar" pkg.MyClass some-more-arguments running the same command from the command line works fine in windows and linux, however when my spawning java process calls the command via Runtime.exec it works in wi...

Java Runtime Exec for VBA script with arguments

I am trying to use Runtime exec() to run a vba script with arguements. I am having trouble passing in the args. I think I need to use the String[] overloaded method for exec. Currently this works: String command = "cmd /c \"\\concat2.vbs\"" Process p = Runtime.getRuntime().exec(command); But I want to run that with arguments and if ...

Java Runtime.getRuntime().exec() alternatives

I have a collection of webapps that are running under tomcat. Tomcat is configured to have as much as 2 GB of memory using the -Xmx argument. Many of the webapps need to perform a task that ends up making use of the following code: Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec(command); process.waitFor(); ... ...

Connecting to SFTP service via Java Runtime process

Under my project, I have a Java class file, inside of which I have a routine which executes the following external SFTP script file: #!/bin/sh echo "cd AV/OASIS" >> sftp echo "put $1 $2" >> sftp echo "get AV/OASIS/$2 $3$2" >> sftp echo "bye" >> sftp /usr/local/bin/sftp -b sftp id@domain cat /dev/null > sftp exit 0 The Java code which ...

Reading streams from java Runtime.exec

I have the following snippet of code: Process proc = runtime.exec(command); errorGobbler = new ErrorStreamGobbler(proc.getErrorStream(), logErrors, mdcMap); outputGobbler = new OutputStreamGobbler(proc.getInputStream(), mdcMap); executor.execute(errorGobbler); executor.execute(outputGobbler); processExitCode ...

Opening an URL with request parameters in IE using Java Runtime class

Hi, I've a code block to open a given URL in default browser. I've problem opening URLs with parameters in IE, When the default browser is FireFox it works fine, but it seems that IE is removing those parameters!!! Any other way to solve this problem? Code I am using is: Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler...

Launching JVM from within another JVM - Bad idea for avoiding code duplication?

I have a Java console application that is launched from a batch script in Windows and a shell script in Linux. In both cases, any command-line arguments (which are complex) are simply passed into the java app, which interprets them using Apache Commons CLI. Now I want to allow users to allocate additional memory to the program. The simp...

Runtime.getRuntime().exec() not launching process

I have a multi-threaded application that launches an external app to do data conversion in preparation for later parts of the application. I have an issue that when I set my thread count higher then 6 concurrent threads, the Runtime.getRuntime().exec() fails to launch the external application (I have also tried using ProcessBuilder with...

Runtime.getRuntime().exec problem win serv 2003 versus win serv 2008

I have some java code as follows: try { String outString ="java -jar C:\\ami\\bin\\ImmediateSubmit.jar 12345 localhost"; Runtime.getRuntime().exec(outString); out.println("SUBMITTED"); } catch (IOException e) { System.out.println("IO Exception parse"); out.println("FAILED"); e.printStackTrace(); } It works fine in win ser...

How to use Java Runtime.exec() with Windows REG utility to Read/Update/Delete entries in HKEY_LOCAL_MACHINE\...\CurrentVersion\Run?

I want to use Runtime.exec() to update the registry for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run using the Windows REG command utility. Need to be able to add/remove/read an entry from the "Run" key to allow my Swing application to run at startup and check if it is configured to run at startup so I can mark the o...

Does "Runtime.getRuntime().exec()" have a bad performance??

Hi there, I want to execute a jar from my own java application. (it's impossible to import that jar a library and start the app as an instance of my own "launcher"). To execute a jar from my own java app...I am using the next lines: String [] cmd = new String [] {"java","-jar","myjar.jar"}; Process process = Runtime.getRuntime().exec(c...

Problems killing child process invoked in Java

Hi, From within my program, I invoke a Linux process, read the output from that process, process it and then sleep until the next iteration. The problem I'm having is that the process I call doesn't always die, even when I do a childProcess.destroy(). Here's the code: while(true) { Process childProcess = Runtime.getRuntime().exec("...

Help regarding Runtime.getRuntime().exec() command usage in Android app

Hi All, I am trying to make use of Runtime.getRuntime.exec() command to copy a folder from one location to another on sdcard. But it seems like it doesn't work Below is the code snippet where I am trying to copy the contents from / sdcard/etc/data to /sdcard/etc/temp/ try { Process process = Runtime.getRuntime().exec("cp -r /sdc...

ProcessBuilder vs Runtime.exec()

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 inconsis...