简体   繁体   English

Eclipse中具有不同输出文件夹的两个不同源文件夹,它们具有相同类型的Java源文件;没有被编译

[英]Two different source folders with different output folders in eclipse having same type java source files;not getting compiled

I am trying to build a very simple java project in Eclipse SDK Version: 3.6.1 Build id: M20100909-0800 我正在尝试在Eclipse SDK版本中构建一个非常简单的Java项目:3.6.1构建ID:M20100909-0800

having two different source folders with different output folders with same java source file. 具有两个不同的源文件夹,以及具有相同java源文件的不同输出文件夹。 But, getting CTE in the project. 但是,让CTE参与该项目。

Below is the .classpath file for project :- 以下是项目的.classpath文件:-

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="myBin" path="mySrc"/>
    <classpathentry kind="src" output="yourBin" path="yourSrc"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

Also find below Project Explorer screenshot :- 也可以在下面的Project Explorer屏幕截图中找到:-

替代文字

I also find this while googling. 我在谷歌搜索时也发现了这一点

Any workaround for this is greatly appreciated. 对此的任何解决方法将不胜感激。 Thanks. 谢谢。 ;) ;)


Edit : 编辑:

Actually, I have a single project, which I am enhancing continuously and want to keep all versions together. 实际上,我有一个项目,我正在不断增强它,并希望将所有版本保持在一起。 I googled this approach from here . 我从这里搜索这种方法。 Any hack for this or better approach is welcomed. 欢迎使用此方法或更好的方法。

You cannot have two classes of the same FQCN ( Fully Qualified Class Name ) in the Eclipse source folders. 在Eclipse源文件夹中,不能有两个具有相同FQCN( 完全合格的类名 )的

However, you can have two classes of the same FQCN on the CLASSPATH. 但是,在CLASSPATH上可以有两个具有相同FQCN的类。 One in the source folder and another in any of the dependencies (eg JAR files). 一个在源文件夹中,另一个在任何依赖项中(例如JAR文件)。 Then the first one found by the class-loader is loaded and used by the JVM ( Java Virtual Machine ). 然后,由类加载器找到的第一个被JVM( Java虚拟机 )加载和使用。 So here the order on the CLASSPATH matters. 因此,这里的CLASSPATH顺序很重要。

Hope this helps. 希望这可以帮助。

The easiest workaround is to give different package name for each source folder. 最简单的解决方法是为每个源文件夹提供不同的包名称。 if you want to keep versions you can do one of: 如果要保留版本,可以执行以下操作之一:

  1. use source control. 使用源代码控制。
  2. use eclipse built in history. 使用历史内置的eclipse。
  3. copy the entire project to a project with the version name, and not only the source folder. 将整个项目复制到具有版本名称的项目,而不仅是源文件夹。
  4. copy the source folder to a dir which is not source a folder. 将源文件夹复制到不是源文件夹的目录中。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM