0

I have create a project under eclipse. Eclipse automatically creates a directory named 'src'. The Source control system I am using imposes a directory structure which begins src/java/com/company_name/package_name/java_class_name.java .Other packages which are dependent i.e. use the java files in other eclipse projects refer to the classes with import com.company_name.package_name.java_class_name.

My question is in order for the above to work I need to create a 'java' directory under the autogenerated 'src' and link this to the directory where my files are starting 'com'. If I select "project-properties-Java Build Path-Add Folder-link source" then specify my directory structure 'src/java' it creates a java directory at the same level as my src directory. If I select add folder it presents me with existing folders only which don't include 'java'. I cannot see a way to resolve this.

4

2 回答 2

1

右键单击 src 文件夹并选择新建/其他.../文件夹(不是源文件夹)。在对话框中输入名称“java”,然后单击“确定”。

但是,这不是你想要的。您真正想要的是删除源文件夹“src”,然后添加一个新的源文件夹“src/java”。这样包名称是“com.blah ...”而不是“java.com.blah ...”。

所以,首先删除 src 文件夹。

  1. 右键点击src
  2. 选择删除
  3. 确认

接下来,创建一个新的源文件夹。

  1. 右键单击项目
  2. 选择新建/源文件夹
  3. 输入“src/java”(不带引号)
  4. 点击确定

现在您有了一个具有正确路径的新源文件夹,并且包名称将与 Eclipse 中的预期一致。

于 2012-07-11T17:29:53.810 回答
0

Zagrev答案的修改替代方案:

您仍然需要从 Eclipse 项目中删除 src 目录

手动创建 Java 子目录。

然后使用 Build Path-> Link Source... 并将其链接到创建的目录。

于 2012-07-11T17:32:55.667 回答