In this video, we’ll look at creating a very
simple project using Eclipse. After I double-click on eclipse.exe, the splash screen appears
and I am then prompted for a workspace folder. Using multiple workspaces can allow you to
organize your different projects by category and not have them all visible in Eclipse at
once. I’ll accept the default folder and continue. I now reach the Welcome screen. This screen
has an overview, samples and tutorials. I’ll proceed to the workbench. If you need to get
back to the Welcome screen, you can select it from the Help menu. Now let’s write a simple Java program. On
the “File” menu, we select new Java project. This brings up a screen where you can give
the name and location of the project. I’ll call this MyFirstProject, and accept the default
location, which is my workspace. Below that it asks what version of Java I wish to use,
and how I want the files laid out. I’ll accept the defaults on those and push “Finish.” Next I need to create a Java class. From the
“File” menu, I select Class. Eclipse is going to store this in the “src” folder and I will
give it the name “HelloWorld.” I want a main method, so I’ll ask eclipse to create a stub
for me. I then pick finish. Now let’s look at the folders Eclipse created.
In my workspace, I have “MyFirstProject”. Inside that are “src”, which is where the
Java source code will go, “bin”, which will contain the compiled classes. You’ll mostly
be interested in what is in the “src” folder and can ignore all the rest. Back in Eclipse, we can see the created project.
There are also windows for task list and outline. I’m going to close these to reduce the amount
of clutter. If you want them back, you can get them from the Window menu, under show
view. You can see that Eclipse has added a lot of code for us, and put a “TO DO” for
us to add code. I’ll add a println. Notice that after I type “System dot”, Eclipse shows
a lot of suggestions. Also, Eclipse is constantly compiling in the background, so if I type
something wrong, like leaving off the “n” at the end of println, a red squiggly appears
under the line indicating there is an error. Hovering over the red “X”, I can see the error
messages. I’ll finish off the code, printing out “Hello World.” To run the program, simply
hit the green “run” button. We can add more than one file to a project.
By simply dragging a file into the project, it is added. Eclipse is an extremely powerful
IDE with lots of options that can be intimidating, but you can also use only a small subset of
it fairly easily.