runtime.exec

Code run by Hudson can't find executable on the command line

I'm setting up my first job in Hudson, and I'm running into some problems. The job monitors two repositories, one containing our DB setup files, the other a bit of code that validates and tests the DB setup files. Part of the code that runs will throw the validated setup files at PostgreSQL, using the psql command line tool, using Runti...

Hudson job hangs at Runtime.exec

I'm running Hudson as a windows service through Tomcat, with no slaves involved. The last build step in the job is a batch file that invokes some Java code. The code uses PostgreSQL's command line tool psql (via Runtime.exec()) to create a database on the local machine and eventually run some tests against it. The job will progress to t...

Problem with starting OpenOffice service (soffice) from Java (command working in commandline, but not from Java)

I want to exceute a simple command which works from the shell but doesn't work from Java. This is the command I want to execute, which works fine: soffice -headless "-accept=socket,host=localhost,port=8100;urp;" This is the code I am excecuting from Java trying to run this command: String[] commands = new String[] {"soffice","-headl...

How do I run a batch file from my Java Application?

In my Java application I want to run a batch file that calls "scons -Q implicit-deps-changed build\file_load_type export\file_load_type" It seems that I can't even get my batch file to execute. I'm out of ideas. This is what I have in Java: Runtime.getRuntime().exec("build.bat", null, new File(".")); Previously I had a python Scons...

How to close command windows with Java

Each time I use Runtime.exec("cmd /c start....") I am opening a cmd window. I would like to create a more seamless application by closing each previous cmd window. How can I do this? If anyone knows of a better way to run a series of commands in the same cmd window rather than opening new ones each time I execute a command, please let m...

A problem with Runtime exec and a custom built RTF editor

I have a class that manages the creation of RTF documents and a method in that class that calls the RTF editor with a xml file for display. All but one user can access this editor without any issues. This one user consistently runs into an issue where their application just hangs. There are no errors in any logs. Normally this kind o...

Is there a way to generate the 8.3 or 'short' (Windows) version of a file name in Java?

In our application, we are allowing users to open files and directories. Java 6 provides us with... java.awt.Desktop.getDesktop().open(file); which works great. However, since we need to ensure Java 5 compatibility, we also implement a method of opening files by calling the start command in cmd.exe... String command = "cmd.exe start...

Runtime.getRuntime().exec(), hide the console screen

I am executing a batch file using Java code. The code is given below: Process proc = null; proc = Runtime.getRuntime().exec("cmd /c start somebat.bat"); With this, the normal command prompt screen gets open. Now I want to suppress/hide the command prompt window(the black one). I found somewhere that if I remove the start attribute fr...

Saving to a subversion repository from Java

I want to save to a subversion repository. I am using the command - svn commit -m \"\" ./cms_test/www My class is: public int doBackup(){ int exitVal=-99; try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("svn commit -m \"\" ./cms_test/www"); exitVal = proc.exitValue(); System.ou...

Runtime.exec() with absolute directory

I would like to use Runtime.exec() to initiate another process in a directory with spaces. (It sounds stupid but I really want to satisfy my curiosity) Details of the problem(simplified version) I have a myprogram.exe locates in C:/Program Files/MyProgram. What I observe: 1). when I call Runtime.exec("C://Program Files//MyProgram//mypr...

Runtime.exec causes duplicate JVM to hang indefinitely until killed (Solaris 10)

All, We are running a J2EE application on WebLogic server 9.2 MP2 with a jrockit 64-bit JVM (27.3.1) on Solaris 10. We call use runtime.exec to call an executable called jfmerge to create PDF documents. We have found that in Solaris, when runtime.exec is called, a duplicate JVM is temporarily spawned to kick off the jfmerge process. ...

Calling a .Net Window-based application using Runtime.getRuntime().exec from a Spring Controller running on Tomcat.

I am calling an exe file called myapp.exe via a Spring Controller; here is the code in the controller: Runtime.getRuntime().exec("D:\vmd\apps\myapp.exe"); myapp.exe is a C# .NET application. If I click directly on myapp.exe using Windows Explorer, the application opens up and runs; however, if I call the command through a Spring Control...

Graphical Sudo for Mac OSX

Hi. I'm designing a little software in java. Don't know the term/definition to what I'm doing, but I'm prompting commands from java to the terminal. Something like this: Process process = Runtime.getRuntime().exec("command"); I've done this before in linux, and I used the gksudo for commands that required root password. Is there any "...

Compressing and Archiving the files in the folder using Java Runtime

Hi, I am trying to Compress and Archive all the files in a folder, using Java Runtime class. My code snippet looks as this : public static void compressFileRuntime() throws IOException, InterruptedException { String date = Util.getDateAsString("yyyy-MM-dd"); Runtime rt = Runtime.getRuntime(); String archivedFile = "myuse...

Runtime.getRuntime().exec() with a non-ASCII string in Windows?

Trying the following method to open an Arabic URL: String cmd = "cmd.exe /C start \"Open file\" \"http://ar.wikipedia.org/wiki/موسوعة\""; Runtime.getRuntime().exec( cmd ); Unfortunately, the URL being opened is http://ar.wikipedia.org/wiki/?????? Any thoughts on why this is or how I could prevent this? Before you ask why I don...

Java Runtime Exec on Windows Fails with Unicode in Arguments

I want to launch a browser and load a web page using Java's Runtime exec. The exact call looks like this: String[] explorer = {"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE", "-noframemerging", "C:\\ ... path containing unicode chars ... \\Main.html"}; Runtime.getRuntime().exec(explorer); In my case, the path contains ...

Mock Runtime.getRuntime()?

Can anyone make any suggestions about how best to use EasyMock to expect a call to Runtime.getRuntime().exec(xxx)? I could move the call into a method in another class that implements an interface, but would rather not in an ideal world. interface RuntimeWrapper { ProcessWrapper execute(String command) throws IOException; } interf...

Running a bash script from the JVM

I'm having trouble running a simple bash script from Java. Specifically: ... try{ ProcessBuilder pb = new ProcessBuilder("/bin/bash", "-c", command); pb.directory(new File(dir)); Process shell = pb.start(); int exitVal = shell.waitFor(); ... where 'command' the absolute path to a bash script that is executable by all and 'dir' is th...

Problem with Java Runtime.exec() when trying to start Nmap.exe

Hi there, I'm using Java 1.6 , Eclipse , Windows 7. I'm trying to run commands in a java program to use NMAP. The code : String cmd[] = { "cmd.exe", "/c","start notepad.exe"}; Process pr = rt.exec(cmd); works fine, but the code: String cmd[] = { "cmd.exe", "/c","start nmap.exe"}; Process pr = rt.exec(cmd); simply doesn't. I...

Using Runtime.exec to fork another instance of the current process.

I'm trying to use Runtime.exec to start a copy of the current process. I am not necessarily interested in a fork because I don't need to share state. Is there a way I can determine the command used to start the current process and just re-run this? ...