0

I'm trying to pinpoint where my code is going wrong and it would help if I could simply not include some classes in my code, and run the program excluding these classes, to see if they are causing the problems.

The only way I can thing of doing it is by moving the classes to another folder, running the program, and then moving them back in if they're not causing the problems. This would become a lot of hassle when I have to do it for a few different classes.

Is there anyway I can simply mark the classes so they don't get compiled?

klippy
  • 225
  • 3
  • 11
  • I expect you mean a class in a Java project? I'd suggest to comment the whole content of the class file out. That should do the trick. – fireandfuel Jul 09 '19 at 12:47
  • That causes problems for me. It will throw an error if these classes aren't populated with something – klippy Jul 09 '19 at 12:51
  • Which eclipse version do you use? – fireandfuel Jul 09 '19 at 13:00
  • Version: 2019-03 (4.11.0) – klippy Jul 09 '19 at 13:02
  • It works for me to comment the whole file out, not only the content of the class, the class and package declaration in your .java file too. eclipse ignores completely empty files oder files without a class or interface definition. Open your class file in the Java editor, press CTRL + A to select all and CTRL + SHIFT + 7 (for macOS it's usally the command key instead of CTRL key) to comment out. Save the file. – fireandfuel Jul 09 '19 at 13:13
  • Okay yeah that does work. I wasn't commenting out the class name and imports etc. before and that causes an error for me – klippy Jul 09 '19 at 13:17
  • See [Skip some file during compilation Eclipse](https://stackoverflow.com/questions/8761504/skip-some-file-during-compilation-eclipse) – SDJ Jul 09 '19 at 17:15
  • How does excluding the class make a difference? In what way are things going wrong when it's present? – nitind Jul 09 '19 at 17:21

1 Answers1

0
  1. Right-click on the package containing the Java file and choose Properties
  2. In the Properties dialog in Resource > Resource Filters click Add Filter...
  3. In the Add Resource Filter dialog select Exclude all and enter the file name (e.g. MyClass.java) in the text field of Filter Details
howlger
  • 27,010
  • 8
  • 46
  • 83