| Using Eclipse | Fall 2020 home |
We will be using Eclipse, a full service Integrated Development Environment for Java in the second half of the semester. (We avoid Eclipse in the first half of the semester so that you get a feel for how things work in command line mode, and know what Eclipse does for you. Besides, you will need to use a command line development mode for other programming languages, so it's good to understand how command line works.)
Eclipse is an open source Interactive Development Environment (IDE) available free at eclipse.org. There have been several older releases of the Eclipse IDE, and the naming convention has changed over the years. Older releases of Eclipse were identified with a release name such as "Eclipse Neon" or "Eclipse Oxygen", or "Eclipse Photon". In 2019, the Eclipse organization changed to name each release of Eclipse with the year, followed by the release within the year. At the beginning of the summer, the latest version was Eclipse 2020-03, but newer versions of Eclipse are available since then. If you switch between the different versions, you will get messages, but as far as I have seen so far, everything still works.
Note: Eclipse is already installed on the Binghamton Unix Lab machines and Unix servers. Even though the version of Eclipse might not be totally up to date, please do not try to install your own version of Eclipse on these machines. If you do so, you will exceed your disk quota, and you won't be able to log on to the machines.
Before installing Eclipse, you should already have a Java Development Kit installed on your machine. See Installing Java for CS-140 for details.
To install Eclipse, go to eclipse.org and click on the "Download" button. This will download the Eclipse installer onto your machine. Run the installer, and choose the very first option "Eclipse IDE for Java Devlopers" and follow the instructions. The Eclipse installation should recognize the Java Development Kit installed on your machine.
arrow_backThe very first time you open Eclipse, it will offer you a "Welcome" window with several options including things like Eclipse tutorials. Feel free to make use of these resources, but eventually, to do real work, click on the "Workbench" button at the upper right. Feel free to unclick the "Alywas show welcome at startup" box. You can always get back to the Welcome screen by choosing "Help/Welcome"
Once you are in the desktop, select a workspace directory. The cs140 directory is a good choice for this. Then, create a new project using File->New->Java Project. Name the java project cs140. From now on, each lab or assignment can be a new package in the cs140 project.
arrow_backWhen you first open Eclipse, there are lots of windows and buttons, but very little to explain what is going on and how things are organized. One way to get more familiar with how things work is to understand the way Eclipse organizes the files you will use to code and run Java programs.
Eclipse manages your code using a hierarchical data structure - analogous to (and actually implemented under the covers as) a file system with directories and sub-directories.
The top level of the hierarchy is your workspace. When you first start Eclipse, you tell it where to find your workspace on your local disk, but it will remember where your workspace is, and use that same location the next time you start Eclipse. We will typically have a single workspace for everything we do in CS-140.
Within each workspace there can be one or more projects. Eclipse keeps track of things like how to build Java programs, and what level of Java libraries to use at the project level. When we first start Eclipse, we will create a CS-140 project to use for all the work we will be doing in this class. (We use the same JDK, the same libraries, etc. for all our work.)
For the most part, once we create our CS-140 project, we don't need to think about it again. However, we may need to update the project parameters to do things like add JUnit test libraries, or fix things if the JDK ever changes.
Use the "Package Explorer" window to explore the hiearchy. The Package Explorer window shows all the projects in your current workspace. Click on the ">" icon to get a list of the packages in a specific project.
Note that if any libraries are associated with the project, you can see a reference to the libraries in the package explorer window, as well as the packages. You should have a reference to the system library named "JRE System Library (JavaSE-11)".
Note that the Eclipse project is equivalent to a module in Java. When you create a new project, Eclipse may ask you if you would like it to create a "module-info.java" file for you. We will not be using modules in CS-140. Nothing we do in this class is sophisticated enough to need a module. If you allow Eclipse to make a module-info.java file for you, it will cause problems for you later on! Please do not create a module-info.java file. If one is created for you, please delete it.
Within each project, there can be many different packages. In CS-140, we will use a different package for each assignment, lab, and phase of the final project. Each package will correspond to a unique Git repository. Note that Eclipse packages are equivalent to Java packages, and may contain source Java code with a file type of .java, as well as other files, such as README.md.
Use the "Package Explorer" window to show all the packages in a specific project, and if you expand the package by clicking on the ">" icon, you can see all the files in a specific package.
arrow_backThis section consists of several hints and shortcuts that may be helpful.