I use Eclipse mainly and sometimes switch to IntelliJ IDEA. I never mix the two together just so I can avoid the problem you describe. Here's what I do (Caveat: there may be other better incantations but this approach isn't too onerous for me -- I'd welcome an opportunity to make it better though if anyone has a better way):
1. Most Important Thing: Use a version control system. The first thing I taught my son when he enrolled in a computer programming course was how to use
git for version control. I think instructors are doing their students a disservice if this is not one of the first things they teach. It's not that hard if you give them some basic commands to follow. Get an account on GitHub and go through their online help. There are also some free books available online, like Pro Git. Don't be afraid of the "Pro" in the title.
2. Exclude any Eclipse or IDEA project files by adding them to your .gitignore file. Google will turn up info on how to do this. Exclude .class files, too. You will mainly only want to keep your
Java source files (*.java) in git.
3. Both IDEs usually support git out of the box. If not, install the git plugin. Each IDE will have its own way of installing plugins. Eclipse has its Marketplace. You will look for the eGit plugin or something similar. Again Google for how to do that.
4. Have a work area for Eclipse and a separate one for IDEA.
5. Eclipse and IDEA both have ways to import projects from a version control system, like from git. When working in Eclipse, import the project from git into your Eclipse work area. When working in IDEA, import your project into your IDEA workarea.
6. Commit your changes to git.
7. When you switch to the other IDE, just update your workarea from git. That should synch you up with the latest changes that you have committed from the other IDE.
This recipe develops some important habits that all programmers should have:
1. Use a version control system
2. Keep work compartmentalized
3. Always commit your work to version control
4. Always update your local workspace from version control to make sure your local files are in synch with your version control system.