Join Todd Perkins for an in-depth discussion in this video Creating a Java project, part of Eclipse Essential Training.
- View Offline
- You can create a Java project in three main ways: You can go to File, New, and then choose Java Project. You can create it from the toolbar or you can right-click in the Package Explorer and choose New Java Project. Up to this point, we've just kept the default settings and given the project a name. So I'm going to type in "ExampleProject" here and here we have the check-box that says, "Use default location," so if we want to create it in the workspace, then we just leave that box checked.
But if we would like to create a project somewhere else on our file system, we can uncheck that box, click Browse, and you can choose another location on your computer. I'm going to check the box 'Use default location.' JRE is for Java Runtime Environment, so which version of Java do you want to use? Here you can choose 'Use an execution environment JRE,' 'Use a project specific JRE,' or 'Use a default JRE.' Up to this point, we've only used the execution environment JRE, which is JavaSE- 1.7.
So you can change that if you'd like to use a different version of Java. Certain projects may require you to use a different version of Java, so you can always change it there. Or if you want to use something for a specific project that maybe requires an earlier or later version of Java, you can use a project specific JRE here. Or you can use a default. And if you'd like to, you can click the button to configure JREs. So when I click that button, I'm taken to Installed JREs and I can see the Java Runtime Environments that are installed on my machine.
If I would like to add extra ones, I can download them and then click the Add button here. Then choose a JRE type, for example, Standard VM. And click Next. And then browse to the Java. And then browse to the JRE home directory to set a new version there. I'm going to cancel out of this now. I'm going to go back to using an execution environment JRE. And then we'll go down to Project layout. Here we can choose to use the project folder as the root for all sources and class files, so that puts your class files in the same folder as your main project folder or you can create subfolders for your project layout, which I'm going to choose here.
Again, you can click the button to configure the default settings and choose the names of the folders that you'd like to be created automatically for you. I'm going to click Cancel. We can also choose to add the project to a working set. A working set is similar to a workspace, but it enables you to have grouped projects without having them necessarily be in a same position on your file system. So now I'll click Next. And here I can define my Java build settings.
And I can import Libraries into my project, if I want. And set the order in which files are imported, if I want to as well. I'm not going to change any of these now. I'm just going to go back to Source and then I'm going to click Finish and create the project. So when you create a new Java project, you can use the appropriate Java Runtime Environment and choose how your project is organized in the file system.
- What is Eclipse?
- Setting up a workspace
- Adding external files to a project
- Installing add-ons
- Refactoring code
- Working with tasks
- Customizing formatting
- Using Git for version control
- Developing Java, PHP, C/C++, Perl, and Python apps with Eclipse
- Setting up testing servers
- Testing apps
- Debugging apps