Well, now I am having a headache - I did my school projects in Eclipse, then I decided to try NetBeans and Idea - now all my projects are marked as Idea, and I can run them in neither IDE. How do you guys prevent this from happening when using different IDEs on the same machine? I recon there is no way to convert Eclipse built projects to NetBeans or Idea, correct? Please, share with me how to fix the situation and to prevent it in the future - I really hate loosing 2 semester work to this stupid issue. Thank you.
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.
One of the annoying things I read in my son's course materials (this was a college-level Introduction to Programming in Java course) was the section about making backups of their work. Making backups of your work is good advice. The annoying part was that the main example for making backups was copying files to a flash drive or external drive. That's a pretty ridiculous thing to teach future programmers. Teachers should give their kids more credit. Like I said, I taught my son how to use git right away. I helped him set up a local git repository. I told him to create an account on GitHub, which he did. I showed him how to use git init, git clone, git add, git status, git commit, git reset, git update, and git push. He was off and running with git in less than 30 minutes. I think he's only one of a few in his class who uses git or some kind of version control system. I think that is pretty appalling.
Lena Sergeenko wrote:Please, share with me how to fix the situation and to prevent it in the future - I really hate loosing 2 semester work to this stupid issue. Thank you.
All your *.java files should still be there. I would create a new directory, then copy all your *.java files there, preserving whatever directory structure you already have in the original. IDE-specific project files are usually kept separate from your Java source files so it should be fairly easy to extract just the *.java files to a new directory.
Then follow my previous advice about using a version control system like git.
Thank you, Junilu! I am familiar with github and used it for my website project once - but how do I run git from Eclipse? I use EE and do not see any mentioning of it in Preferences or elsewhere. I probably need to download EGit - but which one? For Mars, or Mylyn connector or both? Do I need p2 repository (what the heck that is?) if I do not have a team? There is also some Jgit - you see, I have a technical problem now. ))) Can you help me with this, too? Huge thank you for your help!!!
Lena Sergeenko wrote:how do I run git from Eclipse?
I taught my son to run git from the command line. It's not that hard and it's always good to be comfortable working on the command line. I find working with git this way to be much faster than clicking around with the mouse. I'm actually trying to get used to working in tmux so I can start freeing myself from having to use the mouse for many of the things I have to do while programming.
OK I'll try. Oh, and tell your son he is lucky to have such a great mentor right at home - I wish I had somebody like you by my side. )))) Have you thought about doing tutorials? Like video How-To's? I think you would be great.
Anyway, thanks for your help.
You may be interested in knowing that for a while I had several dual-IDE projects. They offered developers the choice of IntelliJ or Eclipse. That was possible because both IDEs allowed free-form project structure (older IDEs notoriously forced you to put specific resources in specific places. So you could have Eclipse .project and .classpath files plus Intellij's equivalent (XML) files. IntelliJ also kept a third file with developer-specific project state in it and that file was excluded from version control to avoid people from polluting each other's workspaces. Eclipse has a separate workspace directory and while all projects within the workspace have resources defined within the workspace (including metadata), the actual project files could be kept in a directory that was external to the workspace, thus allowing both Eclipse and IntelliJ to share the same code directory.
Of course, I don't recommend running both IDE's simultaneously on such a project, since their concepts of file edit history and class compilation wouldn't be kept in sync, but switching back and forth was no problem.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.