TomaszRykala
TomaszRykala

Reputation: 947

Eclipse compilation put lots of .class files in the package folders

I must have done something very stupid which has caused the following situation. Basically after compilation of code which I had compiled successfully lots of times previously, all of the .class files have all of a sudden been put in the package folders, where the .java files are. Some of the .class files have even numbers in the names like.

ClassName.java
ClassName.class
ClassName$1.class
ClassName$2.class
ClassName$3.class
ClassName$4.class

It looks a mess in the Navigator and rebuilding or cleaning the project doesn't make these files go away.

The last code change I made, which has now been reverted was in the class static field:

static {
    if (System.getProperty("os.name").startsWith("Mac OS X")) { CONTROL_PANEL_WIDTH = 225; }
    else { CONTROL_PANEL_WIDTH = 180; }

System.out.println(System.getProperty("os.name")); // this is what I added; perhaps it was stupid
}

I must have done something silly. Can you help please?

Upvotes: 2

Views: 1710

Answers (3)

Kai
Kai

Reputation: 39632

You might have switched your default output folder of your classes, which can be fixed by right click your project -> Properties -> Java Build Path -> Tab Source -> Default Output folder (set it to <ProjectName>/bin)

You could also check the .classpath file in your workspace which have to look like this (the path of the output folder is stored relative):

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <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>

Upvotes: 4

Jerome Cance
Jerome Cance

Reputation: 8183

Right click on your project, click properties

search for java build path,

click on source, here there is the config where the class must go

Don't check "allow output folders for source folder" and check that the path below is good

Upvotes: 2

mcfinnigan
mcfinnigan

Reputation: 11638

Right click your project. Select Build Path / Configure Build Path. Select the Source tab. Ensure that the Default output path is not your /src folder.

Somehow you or eclipse managed to lose the output folder for the compiler.

Upvotes: 1

Related Questions