Search code examples
javaeclipsecompiler-errorspackaging

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

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 :-

alt text

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.


Solution

  • 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.