简体   繁体   English

Eclipse-如何在不让Eclipse查找错误软件包名称的情况下从子文件夹创建源文件夹?

[英]Eclipse - how do I create a source folder from a sub folder without making eclipse look for the wrong package names?

I do have a folder structure given such as: task --> task related non-source stuff, src --> (package1 --> classes), (package 2--classes) 我确实提供了一个文件夹结构,例如:任务->与任务相关的非源文件,src->(package1->类),(package 2类)

Now whenever I add task/src to the build path, Eclipse always gives me errors for the packages - it keeps saying it wants src.package1 instead of just package1. 现在,每当我将task / src添加到构建路径时,Eclipse总是给我错误的软件包-它总是说它想要src.package1而不是仅package1。 I suppose that is because it interprets task as the basefolder and src already as the first package - how do I get Eclipse to understand that src is NOT a package? 我想这是因为它已将task解释为basefolder,而src已经作为第一个软件包-我如何使Eclipse了解src不是软件包?

I am using Eclipse Indigo, and I am not allowed to change the folder structure. 我正在使用Eclipse Indigo,并且不允许更改文件夹结构。 Help would be appreciated. 帮助将不胜感激。

I just tried to do the same - I created the following folder structure (at first none of them were source folders): 我只是想做同样的事情-我创建了以下文件夹结构(起初它们都不是源文件夹):

lib - ab lib-Ab

Then opened the Build properties, and added lib/ab as a source folder. 然后打开Build属性,并将lib / ab添加为源文件夹。 Then I created an ABC.java in the ab package in the lib/ab source folder and it worked (in Eclipse Indigo, and I am reasonably sure that it worked before as well). 然后,我在lib / ab源文件夹的ab包中创建了一个ABC.java,并且它可以工作(在Eclipse Indigo中,并且我有把握地肯定它也可以工作)。

You can have multiple source folders on your build path. 您的构建路径上可以有多个源文件夹。 Therefore I would recommend to delete src from the build path and instead add src/package1/classes and src/package2/classes . 因此,我建议从构建路径中删除src ,而是添加src/package1/classessrc/package2/classes

Note that the compiled classes will go as before in the bin folder now for both packages. 请注意,对于这两个软件包,已编译的类现在将像以前一样进入bin文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Eclipse,Java项目-如何添加源文件夹,其中文件夹名称是软件包名称的一部分? - Eclipse, Java project - How do I add a source folder where the folder name is part of the package name? 如何在eclipse中的源文件夹下创建文件夹? - how to create folder under source folder in eclipse? 如何使用Gradle将文件夹设置为Eclipse中的源文件夹? - How do I set a folder as a Source Folder in Eclipse with Gradle? 我可以在eclipse中创建包内的文件夹吗? - Can I create folder inside package in eclipse? 在src目录中的eclipse中添加文件夹而不使其成为包 - Adding folder in eclipse in src directory without making it package 在eclipse中,是否可以在不更改源文件夹的情况下更改默认包的内容? - In eclipse, is it possible to change what the default package is without changing the source folder? 在eclipse中的包内的文件夹内创建源文件 - create source file inside a folder within a package in eclipse 如何在Eclipse中创建文件夹? - How to create a folder in Eclipse? 如何在源 package 文件夹子文件夹中创建 txt 文件(源 package -> 发票) - How to create txt file in source package folder sub folder ( source package -> invoice) 如何在eclipse中创建两个项目以指向一个源文件夹 - How to create two projects in eclipse to point to one source folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM