• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :


import java.io.*;

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) {
System.out.println(line);
}
int exitVal = pp.waitFor();
System.out.println("Process exitValue: " + exitVal);
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}

when i try 2 run this code:

here i am getting this sort of error:


java.io.IOException: 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>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
at java.lang.Runtime.exec(Runtime.java:591)
at java.lang.Runtime.exec(Runtime.java:429)
at java.lang.Runtime.exec(Runtime.java:326)
at Test3.main(Test3.java:8)
CreateProcess: C:\convert\nconvert -out png -o c://out1//%%.png c://ok//*%.*% error=193


pls help me in this issue.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ...
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FYI: some pitfalls to watch out for when using Runtime.exec():
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you should use single-forward-slashes, or double backward.
 
reply
    Bookmark Topic Watch Topic
  • New Topic