This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Reading nconvert.exe in java??????????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading nconvert.exe in java???????????" Watch "Reading nconvert.exe in java???????????" New topic

Reading nconvert.exe in java???????????

Jonk kulsh

Joined: Feb 04, 2005
Posts: 7
I need to execute an nconvert.exe file using java program.The Process class here converting all images format present in ok folder and show it in .bmp format in out folder

this is the code that i wrote :


public class Test3 {
public static void main(String[] args) {
Runtime run = Runtime.getRuntime();
try {

Process pp=run.exec("C://convert//nconvert -out png -o c://out1//%%.png c://ok//*%.*%");
BufferedReader in =new BufferedReader(new InputStreamReader(pp.getErrorStream()));
String line;
while ((line = in.readLine()) != null) {
int exitVal = pp.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Exception e) {

when i try 2 run this code:

here i am getting this sort of error: CreateProcess: C:\convert\nconvert -out png -o c://out1//%%
.png c://ok//*%.*% error=193
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(
at java.lang.ProcessImpl.start(
at java.lang.ProcessBuilder.start(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at Test3.main(
CreateProcess: C:\convert\nconvert -out png -o c://out1//%%.png c://ok//*%.*% error=193

pls help me in this issue.
Paul John Summers

Joined: Apr 09, 2003
Posts: 15
I've never tried to execute a command using the native Runtime but according to the API, your argument to Runtime.exec should be a String array where each element is a token of the command line string. So, instead of...

It should be ...
Hung Yee

Joined: Dec 22, 2004
Posts: 18
FYI: some pitfalls to watch out for when using Runtime.exec():
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

I guess you should use single-forward-slashes, or double backward.
I agree. Here's the link:
subject: Reading nconvert.exe in java???????????
It's not a secret anymore!