1. Introduction to Eclipse
We use application Eclipse to edit, test, and run Java programs. It is called an IDE (Integrated Development Environment. In this little module, we introduce you to the basics of Eclipse. You will not completely understand the Java code we write; just concentrate on how we are using Eclipse. Besides showing you how to use the IDE in a basic fashion, we give instructions on how to set various preferences, e.g. ensuring that line numbers appear in the editing pane.
The Eclipse workspace
A project is a program that you are writing in Eclipse. Eclipse keeps projects in a workspace. The workspace is just a folder/directory somewhere on your harddrive where Eclipse keeps information about your projects. When you install Eclipse, you can tell Eclipse where to put the workspace. Put it where you can get at it if you have to. On a MAC, you might put it in your user directory in a folder called Eclipse or Workspace. On a Windows machine, you could put it in C:\workspace. Eclipse keeps a file or two in the workspace that contains not only the projects but information about them (called metadata). Don't mess with that file.
For each assignment in this course, create a new project within the workspace. Keep things well organized. When you insert a .java file into a project within the workspace, you either copy the file or link to it. For this course, we suggest that you always copy the file into the workspace.
Basic terminology.
1. A Java class is a description of objects, which can contain methods (functions, procedures) to be called. You will learn about Java classes beginning in lecture 2 of CS2110.
2. A package is a collection of classes. If you are writing them, they will be in a directory or folder on your hard drive.
3. An Eclipse project is a program that you are writing using Eclipse. It consists of a bunch of classes. Every time you want to start a new program, say for a new assignment, you create a new project for it. We can also say that the project contains a Java program.
4. A Java application is a Java program (collection of classes) that has a certain method, main, that can be called to run the program.
Creating a project and a class and running it.
This video introduces you to the Eclipse window. It shows you how to (1) create a project, (2) create a class (within the project) that is an "application", and (3) run that application. (5:45 minutes) Read it here: eclipseIntro.pdf
About "hello" in 5 languages
The previous video printed "hello" in the 5 most popular languages, in order of popularity. They are given below, with their meanings. One reason for showing you this is to show that characters from just about all languages can be used in Java, not just the roman letters and numerals to which we are accustomed.
Chinese: 你好 ni hao a respectful hello
Spanish: hola
English: hello
Hindi: नमस्ते namaste I bow to you; the divine within me bows to the divine within you
Arabic: السلام علي
as-salam alaykom peace be upon you
See this webpage: en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers
2. Line numbers and other formatting preferences
Read this page to see how to change settings so that line numbers appear in the editing pane. It shows a few other things too.
3. Reset the Eclipse window layout
Read this page to see how to reset the Eclipse layout when it gets messed up.
4. Syntax help
The Eclipse editor can help with typing, e.g. adding a semicolon where necessary, and inserting a closing parentheses ")" when you type an opening one "(". Read this page to see how to set your preferences to enable this help.
5. See two Java files open at the same time
This video, in under 1 minute, shows you how to have two files open in the editing pane at the same time. This is useful when one has calls to methods in the other. Here's an example. One class is being developed and tested; the other is a testing class that is being developed to test the first class. (52 seconds). Read it here: twoEditingPanes.pdf
6. TODO comments
Multiline comments that start with TODO play a special role in Eclipse. Read this page to learn more.
7. JUnit testing
Read this page to learn about JUnit testing in Eclipse. It shows you the basics of JUnit testing. You can also learn how to ensure that all your expected tests were actually carried out. Some students think they ran certain tests but didn't, and their programs contain errors because of this, so this is important.