I am struggling with ProcessBuilder folks! I want to run the utility 'nativetoascii' in. I can run it on the command line and also via Runtime.exec() with no problems.
My code is:
'
String command = "\"C:\\Program Files (x86)\\Java\\jdk1.6.0_32\\bin\\native2ascii\"";
String encoding = " -encoding ";
String utf8 = "UTF8 ";
String inputFile = "C:\\Users\\joe\\Desktop\\resources\\encoding\\orig.properties ";
String outputFile ="C:\\Users\\joe\\Desktop\\resources\\encoding\\convertedViaProcessBuilder.properties";
List<String> commandArgs = new ArrayList<String>();
commandArgs.add(command);
commandArgs.add(encoding);
commandArgs.add(utf8);
commandArgs.add(inputFile);
commandArgs.add(outputFile);
ProcessBuilder builder = new ProcessBuilder(commandArgs);
Process p = builder.start();
p.waitFor();
I have also written code to read the output from the process and it says:
Usage: native2ascii [-reverse] [-encoding encoding] [inputfile [outputfile]]
Clearly I'm doing something wrong with the command and its arguments. Can anyone tell me what I'm doing wrong? Thanks.