I am working on a Java project together with a collaborator, and we are both using the Eclipse editor. What I want to do is to be able to share the .java files with him so that we can both edit it separately but see what has the other has written. Currently, I am doing this is an ad-hoc way by sharing a Dropbox folder that contains the project. However, this approach does not work well because he is using a different version of Java (as he runs a Mac while I am using Windows). For me to run the project, I would have to clear all the .class files that he has created which will appear on my computer since Dropbox just shares all the files.
I have heard of CVS as a way to manage file sharing among developers, but it sounds like a lot of work. I don't know for example how to get a CVS server or what to do to get it to work. Is there an easy and straightforward way to enable us to work together on the same Java project? Is GitHub the answer?
This is definitely the job of source control, as other answers have mentioned, Git or SVN are probably your best choices. Git is the newer one and is gaining a ton of popularity (probably thanks to GitHub).
GitHub is pretty easy to learn and can even take care of a lot of the more difficult tasks for you with their new GitHub for Windows client. They also have a GitHub for Mac client. Once you are more familiar with the tool you can get the EGit plugin for eclipse so you can control the source control directly from your IDE.
Additionally, GitHub created an online interactive tutorial for learning git.
As for clearing out class files (and also your .settings and .project and .classpath files from eclipse), you can instruct git to ignore these types of files using a .gitignore file. You can find templates for various languages (including Java) here.