File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading nconvert.exe in java???????????" Watch "Reading nconvert.exe in java???????????" New topic
Author

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

Jonk kulsh
Greenhorn

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 :


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

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
Greenhorn

Joined: Dec 22, 2004
Posts: 18
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

Joined: Jun 02, 2003
Posts: 1923

I guess you should use single-forward-slashes, or double backward.


http://home.arcor.de/hirnstrom/bewerbung
 
GeeCON Prague 2014
 
subject: Reading nconvert.exe in java???????????