2013-11-22 60 views
7

鏈接名稱爲「SRC」外部源文件夾這不是一個關於日食的Java項目鏈接源問題在Eclipse項目

是否有可能在Eclipse中添加名爲「SRC」外部的文件夾中源文件夾。 這裏的問題是保持外部文件夾名稱爲「src」而不是任何其他名稱;要做到這一點,我試圖從標準的Eclipse Java項目中刪除src和bin文件夾,然後嘗試「鏈接源」,但不起作用。

有沒有其他辦法可以讓這種情況發生?

這使得Eclipse java項目的src實際上指向名爲「src」的外部文件夾? 輸出文件夾「bin」也存在類似的問題。

System Information 
OS: Windows 8, 32 bit 
Eclipse: 3.7 

感謝。

+2

什麼對Link Source不起作用? –

+0

@aetheria當源文件夾已經存在時,我無法添加名稱爲src的另一個源文件夾,當我刪除原始src文件夾並嘗試添加外部src文件夾時,它仍然無法識別它。還注意到,即使我刪除了原始的src文件夾; .classpath文件不會更改,並且不斷抱怨缺少源文件夾。 – Ayusman

回答

6

您需要使用Eclipse從項目配置中刪除現有的源文件夾,然後將其從文件系統中刪除,然後可以將外部鏈接的源文件夾添加爲「src」。

  1. 該項目的「Java構建路徑」,然後單擊鼠標右鍵,彈出「屬性...」

  2. 選擇「源代碼」選項卡以顯示源文件夾列表上構建路徑。

  3. 選擇「yourproject/src」並單擊「刪除」按鈕。這將從項目中刪除它(和.classpath文件)。

  4. 快出來並物理刪除文件夾。

  5. 回到那個對話框,這次點擊「鏈接源...」。它現在應該工作。這個對我有用。

0

它有點難看,但你可以在你的文件系統中創建一個硬鏈接。在Windows命令行中,使用mklink /H src d:\path\to\external\src

我知道以下內容幾乎不會有用,但是:想一下不同的方法。

5

爲了與外部文件夾鏈接,我們需要的,如果任何文件夾中已經包含「SRC」或更好刪除該文件夾存在同名的文件夾重命名。之後,你可以鏈接使用下列方法的任何外部文件夾:

方法:1 - (請通過代碼手動鏈接):

1. Open the .project file from root folder of your workspace. 
2. Include the below code with your file path: 
    <linkedResources> 
     <link> 
      <name>folder_name_list_in_your_project</name> 
      <type>2</type> 
      <location>folder_path_to_include</location> 
     </link> 
    </linkedResources> 
3. Save the file and refresh the project to include the external folder in your project. 

方法:2 - (使鏈接通過用戶界面手動):

1. Right click the project, select "Build Path -> Configure Build Path". 
2. Choose "Source" tab. 
3. Click "Link Source" button. 
4. Click "Browse" to choose the folder. 
5. Enter the folder name in "Folder name" field to list the external name in your project. 
6. If you need to add the pattern for include and/or exclude file, click "Next" and enter the pattern. Then click "Finish". 
7. Otherwise click "Finish". 

它爲我,並希望我的步驟也幫助你。