i'm executing a jar file in java. so far my code works perfectly.
im executing epubcheck via java because its a console application
here is the address of the epubcheck
except when the name of the file that i need to browse contains
' sign
and space on the folder name or space on the file name.
here is the error on folder name
Unrecognized argument: 'Files\1.epub'
here is the error when the file name contains '
Unrecognized argument: 'the'
this is my code
String a = System.getProperty("user.dir") + "\\epubcheck-4.0.1\\" + "epubcheck.jar";
Process p = Runtime.getRuntime().exec("java -jar" + " " + a + " " + selectedFile.getAbsolutePath());
here is how to run the epubchecker
java -jar epubcheck.jar file.epub
but when i run it on command prompt manually it didn't give me an error
解决方案
You should quote the tokens that make up your command line. Use the .exec(String[]) version
Runtime.getRuntime().exec(new String[]{"java"
, "-jar"
, a
, selectedFile.getAbsolutePath()});