33

Is there any way to skip some Java files when compiling under Eclipse?

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
  • 1
    You can comment the entire file, empty Java files are compilable. – Bhushan Jan 06 '12 at 17:04
  • 2
    any specific reason ignore those Java files? – kosa Jan 06 '12 at 17:04
  • 3
    I am refactoring some code I didn't write and there are classes which contains errors or if not are unused. It bothers me to see them on the class list so I want to put them aside without deleting them. – UmNyobe Jan 06 '12 at 17:12
  • 3
    You shouldn't keep unused classes in your project. Rather delete them and let your version control system revert them if you find out that you need them again. – 0lukasz0 Jan 06 '12 at 17:23

5 Answers5

39

Remove the class from the build path. You can do this for a single file or group of files by selecting them in the Project Explorer, then right click → Build Path → Exclude.

enter image description here

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
4

You can always exclude the item from being built. Right click on the file and go to build-path. Then click exclude.

Max
  • 5,799
  • 3
  • 20
  • 27
1

Delete (or move) them. It can't compile what isn't there ;)

Note: Other forms of removing the content you don't want compiled also work.

cdeszaq
  • 30,869
  • 25
  • 117
  • 173
1

This page should help you. If you wish to remove a file from compilation you can delete it, as cdeszaq suggested, or you can change the extension of it(For example if you have test.txt changing it to test.txtz would pretty much make it un-openable)

Bugster
  • 1,552
  • 8
  • 34
  • 56
0

There's another way to do it. I discovered it by first using the Build Path -> Exclude option in other answers, as Eclipse said something about configuring filters.

Right click the project -> click Properties -> click Java Build Path -> click Source tab -> select ProjectName/src -> click Edit... (or double click Excluded) -> add an Exclusion pattern like com/blah/blah/blah/, potentially with wildcards.

It looks like the wildcards are your standard * and ?, but they also have **, which appears to be for wildcarding any number of folders, which must imply that * and ? are for only wildcarding a single file/folder name.

Andrew
  • 5,839
  • 1
  • 51
  • 72