exec not working with java 1.7.21, but in netbeans works fine -
i made little program , worked fine, now. first, mux xml chapter file in mkv file, muxed mkv file. day ago updated java 1.7.21 , think problem why not working now. it's little strange, when run in netbeans fine, when build , run .jar file, not working. create xml file, not mux in mkv file (and because not muxed not delete xml file). here code: (filename=xml file path; mkv=mkv file path)
public void muxing() { try { runtime rt = runtime.getruntime(); process p = rt.exec("c:\\program files\\mkvtoolnix\\mkvpropedit.exe --chapters \""+filename+"\" \""+mkv+"\""); if (p.waitfor()==0) { file xmlfile=new file(filename); xmlfile.delete(); } } catch(exception e) { system.out.println(e.getmessage()); } } the program worked java 1.6 , think 1.7.17 too. win7 32bit. sorry bad english.
oracle has made breaking changes runtime.exec() in java 7 update 21 (and 6 update 45).
if program name contains spaces, need specify command , arguments in array:
process p = runtime.getruntime().exec(new string[] { "c:\\program files\\mkvtoolnix\\mkvpropedit.exe", "--chapters", "\""+filename+"\"", "\""+mkv+"\""}); another option use java.lang.processbuilder:
process p = new processbuilder("c:\\program files\\mkvtoolnix\\mkvpropedit.exe", "--chapters", "\""+filename+"\"", "\""+mkv+"\"").start(); as stated oracle:
applications need launch programs spaces in program name should consider using variants of
runtime.execallow command , arguments specified in array.alternatively, preferred way create operating systems processes since jdk 5.0 using
java.lang.processbuilder. processbuilder class has more complete api setting environment, working directory , redirecting streams process.
Comments
Post a Comment