How do I make any project a Java project in Eclipse? How do I make Eclipse recognize a project as a Java project so that I can the Java features when I am managing the project?
Solution
Here's how to make any project a Java project in Eclipse.
Step 1: Modify .project
First back up your original .project which lives at the root folder of the project. Then use the following as the .project file.
Note: If you don't see the file, click on the down arrow in Package Explorer, go to Filters, uncheck .* resources.
<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>MultiMediaPlayer</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription>Once you are done right click on the project's root folder in Package Explorer and select Properties. You should see Java Build Path. Configure it to point to the JRE library you want. In my case I am using C:\Program Files (x86)\Java\jre7. You may need to go to Window -> Preferences -> Java -> Installed JREs to add and select the default JRE.
Note: My JDK contains the actual source code. I prefer it to the JRE because with the former I'll be able to navigate to the source code of any primitive Java class such as java.lang.String. You can download the JDK from the Java website.
Observe in Package Explorer that you see JRE System Library [jre7] in the root project folder. Also the icon next to the folder name should have a 'J' at the top right corner.
Now Eclipse should treat this project a Java project and allows you to exercise any Java-specific features. One of them is content assist: You should be able to control + mouse click any Java class name and any of its methods and navigate to the right place.
Note: If your problem is not fixed restart the project by going to File -> Restart.
Related Articles
Fixing Java No Class Def Found Error and Class Not Found Exception in MINUTES!
How Does Java Know Where to Find Core Libraries?
Solving Java JDOM Jar Cannot Find Symbol Errors!
Fixing Java No Class Def Found Error and Class Not Found Exception in MINUTES!
How Does Java Know Where to Find Core Libraries?
Solving Java JDOM Jar Cannot Find Symbol Errors!
Questions? Let me know!