Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jonk kulsh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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.
 
Paul John Summers
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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 ...
 
Hung Yee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you should use single-forward-slashes, or double backward.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic