I am trying to build a very simple java project in Eclipse SDK Version: 3.6.1 Build id: M20100909-0800
having two different source folders with different output folders with same java source file. But, getting CTE in the project.
Below is the .classpath file for project :-
<?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 :-
I also find this while googling.
Any workaround for this is greatly appreciated. Thanks. ;)
Edit :
Actually, I have a single project, whi开发者_如何转开发ch 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.
However, you can have two classes of the same FQCN on the CLASSPATH. One in the source folder and another in any of the dependencies (e.g. JAR files). Then the first one found by the class-loader is loaded and used by the JVM (Java Virtual Machine). So here the order on the CLASSPATH matters.
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:
- use source control.
- use eclipse built in history.
- copy the entire project to a project with the version name, and not only the source folder.
- copy the source folder to a dir which is not source a folder.
精彩评论