aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Class in Eclipse won't go away...and now it doesn't compile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Class in Eclipse won Watch "Class in Eclipse won New topic
Author

Class in Eclipse won't go away...and now it doesn't compile

Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
I don't get Eclipse. First off, I created a class in Eclipse, but then shortly afterwards I deleted it, thinking I wouldn't need it. Now I think I want that class again (separate from an inner class), but everytime I try to create a new class with that name (even though I deleted both the .java and .class files), Eclipse says "Type Already Exists." I don't see how that's possible when I've deleted the .java and .class files. Can somebody help me with this.

...even better now. I must have hit somethign wrong, I think it was project-->clean. I thought that would clean up the problem I had above, but it didn't. Instead it deleted all my classes, but now when I hit run, Eclipse isn' compiling my .java files, and it just keeps saying "java.lang.NoClassDefFoundError:, Exception in Thread "main"" because it isn't compiling my files, that's why. Can somebody please help. Eclipse is so frustrating.
Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
well now it seems like even though I explicitly set eclipse to build [the project] automatically it won't rebuild the project. If I make a change to my .java file, it will update the .java file but it won't re-run the compiler to compile that file. I don't understand why, I'm sure it's something I'm not doing, but I thought setting the project-->build automatically option would do it. Can somebody please help.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
delete the content of the bin folder for your project.
Most likely something was left behind there, and sometimes Eclipse isn't smart enough to clean up after itself.


42
Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
Sorry I don't see a bin folder. The only things that I see that might relate to the project, within the folder my project is in, is .metadata, .settings, .classpath, and .project. None of which have content that looks like it refers to some missing class.

Can you confirm that bin folder? And also now, it won't even compile my code every time I click the run button. It just saves the .java file, but I guess deciding it doesn't feel like compiling as well.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16308
    
  22

Try not to edit the .project or .classpath files directly. Unless you know what you're doing, you can get into big trouble. Normally Eclipse itself will handle those files.

Eclipse will hide your bin folder in the Java Perspective. The Java Perspective thinks that the only thing you're interested in is the source files. Switch to the Resource Perspective. It acts more like a traditional file explorer - it shows everything, including the .classpath and .project files.

If you still don't see your bin folder, bring up the Project Properties editor and look at the Java Build section. It should show what folder(s) it's using for source code and what folder(s) it compiles into.

If you have automatic builds turned on (the default), Eclipse will compile every time you save a Java file. Otherwise you can run the compile manually.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
or learn to use the rest of your computer, the part outside Eclipse
The bin folder is there, in your project directory (unless you explicitly told Eclipse to put it elsewhere), and named bin (unless you explicitly told Eclipse to name it differently).
Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
So i started from scratch I started a new project. Created a /src folder in the main directory, and imported all my .java files into there. Now i wanted to do a little experiment. I didn't create any working sets, so in theory none of my files should be built when I hit run correct? But even though I have no working sets under Project->Working Sets, my code still compiles each time.

So I guess I'm not understanding what working sets really are, or how to control what gets compiled, or how to Eclipse to compile certain files. Can somebody explain?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
A working set is just a filter for the views into your workspace. It doesn't have any effect on what eclipse does, just on what you see.

Why don't you want Eclipse to compile all your files?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
I do want to use Eclipse to compile all my files, I'm just not sure why it doesn't. My files have never moved, and I didn't think I changed anything about where or which files to compiles, but Eclipse just kind of stopped compiling my files, and just running the files that were already compiled (or worst yet, if none were compiled, it just can't find the .class file).

Perhaps I changed where Eclipse thought my source files were, or perhaps I changed what Eclipse thought I should compile. Any idea where to do somethign like that?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Wilson Mui:

Perhaps I changed where Eclipse thought my source files were, or perhaps I changed what Eclipse thought I should compile. Any idea where to do somethign like that?


Yes, in the project properties, under "Build Path", if I remember correctly.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Class in Eclipse won't go away...and now it doesn't compile