Java DefaultExecutor在Windows 7上的长路径上失败错误=267
环境:Java DefaultExecutor在Windows 7上的长路径上失败错误=267,java,windows,Java,Windows,环境: 视窗7 HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled=1(类型:REG\U DWORD) 下面的命令在Windows 7上运行良好: C:\Users\dev\Documents\projects\projectx_solution\java\projectx\build\bin\squeezer -R 1 C:\Users\dev\Documents\work\w1\SPOH_ANO12_PDC2
- 视窗7
- HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled=1(类型:REG\U DWORD)
C:\Users\dev\Documents\projects\projectx_solution\java\projectx\build\bin\squeezer -R 1 C:\Users\dev\Documents\work\w1\SPOH_ANO12_PDC2.fast -L \\?\c:\Users\dev\Documents\jira\work\ABC04214017-long-path-qwertyuioplkjhgfdsazxcvbnm\qwertyuioplkjhgfdsazxcvbnm2\qwertyuioplkjhgfdsazxcvbnm3\qwertyuioplkjhgfdsazxcvbnm-qwertyuioplkjhgfdsazxcvbnm4\qwertyuioplkjhgfdsazxcvbnm5\qwertyuioplkjhgfdsazxcv\qwertypoiuyalskdjfhg\ABC04214017_03.raw_fhhzcqaj_wLM(4)\objs\RemPartic.fast -H 100000
但是当我试图通过Java的DefaultExecutor运行相同的命令时
executor.execute(cmdLine);
然后我得到以下IOException:
“无法运行程序…创建进程错误=267,目录名无效”
这在某种程度上与Windows长路径限制有关。有人知道解决方案/解决方法吗?谢谢大家! 您可以使用普通的旧java进行尝试:
Runtime runtime = Runtime.getRuntime();
String[] cmd = { "C:\\Users\\dev\\Documents\\projects\\projectx_solution\\java\\projectx\\build\\bin\\squeezer",
"-R",
"1",
"C:\\Users\\dev\\Documents\\work\\w1\\SPOH_ANO12_PDC2.fast",
"-L",
"c:\\Users\\dev\\Documents\\jira\\work\\ABC04214017-long-path-qwertyuioplkjhgfdsazxcvbnm\\qwertyuioplkjhgfdsazxcvbnm2\\qwertyuioplkjhgfdsazxcvbnm3\\qwertyuioplkjhgfdsazxcvbnm-qwertyuioplkjhgfdsazxcvbnm4\\qwertyuioplkjhgfdsazxcvbnm5\\qwertyuioplkjhgfdsazxcv\\qwertypoiuyalskdjfhg\\ABC04214017_03.raw_fhhzcqaj_wLM(4)\\objs\\RemPartic.fast",
"-H",
"100000"
};
Process process = runtime.exec(cmd);
InputStream in = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
希望这有帮助