[英]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:
如果要保留版本,可以执行以下操作之一:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.