1. 程式人生 > >windows下eclipse編譯報錯:CreateProcess error=206

windows下eclipse編譯報錯:CreateProcess error=206

windows下,eclipse中執行junit出現錯誤提示: 
Exception occurred executing command line. 
Cannot run program "D:\Program Files\Java\jdk1.6.0_30\bin\javaw.exe" (in directory "D:\work\mywork\20120829_159367_2\biz\product"): CreateProcess error=206, ÎļþÃû»ò)չÃû 

原因是在Windows下命令列支援的字串長度是有限制的, 
在計算機上執行 Microsoft Windows XP 或更高版本,可以在命令提示符下使用的字串的最大的長度 8191 個字元。  

在執行 Microsoft Windows 2000 或 Windows NT 4.0 的計算機上, 將最大長度可以在命令提示符下使用的字串的為 2047 個字元。 
(參照微軟官方文件:http://support.microsoft.com/kb/830473/zh-cn) 

這個是eclipse的bug,參考:https://bugs.eclipse.org/bugs/show_bug.cgi?id=327193 
解決辦法: 
(1)下載修復包:https://bugs.eclipse.org/bugs/attachment.cgi?id=219900 
(2)把本地eclipse的eclipse/plugins/org.eclipse.jdt.launching_3.4.*.jar複製到一個安全的地方,便於恢復。 

- copy your eclipse/plugins/org.eclipse.jdt.launching_3.4.*.jar to a safe place outside of the plugins folder, so that you always have a way to revert 
- close Eclipse 
(3)把jar重新命名為zip 
- rename the *.jar to *.zip 
(4)開啟zip包,拷貝下載的修復包裡面的四個class檔案到org\eclipse\jdt\internal\launching裡面 
- open the zip file and copy the 4 class files from the attachment to org\eclipse\jdt\internal\launching (replace existing files) 

(5)進入META-INF目錄,刪除除了MANIFEST.MF以外的所有的檔案 
- go to META-INF in the zip file and delete all files except MANIFEST.MF 
(6)解壓MANIFEST.MF,刪除以 "NAME:"開頭的所有的entry(兩行是一個entry) 
- extract MANIFEST.MF to your disk and edit it with a text editor 
- remove everything starting from the first "NAME:" entry 
(7)保證MANIFEST.MF檔案的結尾有兩個空行 
- make sure you leave *two* (2) line break characters at the end of the file! 
(8)儲存MANIFEST.MF進zip包 
- save the MANIFEST.MF and copy it back into the zip file 
(9)zip包重新命名為jar 
- rename the *.zip back to *.jar 
(10)放到eclipse下面,替換之前的jar