Files get opened in wrong editing area

You should reset the perspective Window -> Reset Perspective...


The shared area is the default location to open files. The files remain open in the shared area across different perspectives such as Java and Debug so that you can switch between them while working on the same files. You'd generally drag a file outside the shared area to work on it without it appearing in other perspectives.

It's hard to position the shard area view by dragging it, but you can drag the surrounding views in place around it to get it where you want.