How to change an Eclipse default project into a Java project
Want to turn a default project into a Java project? Just add some Java nature into it! Here's how:
- Close the project in Eclipse.
- Edit the
.project
file in the project's root:
- Save and reopen in Eclipse. It's now a bona fide Java project!
Backing up the default project
Don't be reckless with your code if something goes wrong, always backup your project before tinkering with configurations.
Navigate to: Project โ Export โ Archive File to safely backup your work.
Infusing Java Nature via Project Properties
Comfortably nest in Eclipse's GUI if you're feeling sketchy about manually infusing Java nature.
Right-click on the project โ Properties โ Project Facets โ Check Java. After this, Eclipse shall embrace the project as its own Java child.
Configuring project build path
The project is only half-dressed without the right Java Runtime Environment (JRE).
To get fully prepared, go to: Project โ Properties โ Java Build Path โ Libraries โ Add Library... โ JRE System Library.
Select your desired JRE or JDK, and now you've got a project fully clad in Java!
Maven projects
Does your project boast a pom.xml
? Well then, you're one click away from transforming the project into Java.
Right-click on the project โ Maven โ Update Project...: with Force Update of Snapshots/Releases checked. Bam! Your Maven project has now donned its Java cap!
Considering Eclipse versions
Like a picky cat, each Eclipse version purrs at its own unique project configuration!
Keep this in mind:
- Eclipse 3.3.2 and earlier: specify the project type during checkout
- Eclipse 4.9.0 and later: there's a one-stop shop โ Project Natures page, to add Java nature all at once.
SVN checkout prowess
Is SVN your bag? Specify project type during checkout โ New Project Wizard instead of fiddling with project configurations manually.
Breathe life into old/legacy projects
Got a non-Java, legacy or default project?
You can convert the project to a faceted form by going to: Project โ Properties โ Project Facets โ Click Convert to faceted form..., and then add the Java facet. Don't forget to wave the wand on source (src
) and output (bin
) folders.
Dealing with potential issues
Changing files manually can invoke the wrath of the Eclipse XML Deity. So remember the following:
- Be cautious while editing
.project
and.classpath
. - The Eclipse Interface is a safer bet; XML edits are a last resort.
- Clean the slate after meddling with files: Project โ Clean.
- Hit F5 or Right-click on the project โ Refresh, if errant issues rear up.
Remember: Manual conversion might not enable all Java-specific features. Plugins or specific project settings may still require you to manually configure them.
Was this article helpful?