From CDOT Wiki
Revision as of 19:03, 2 February 2011 by Qinzhi (talk | contribs)
Jump to: navigation, search

Basic Lab:

 1. Preparing Eclipse     
    1)Goto Eclipse from
    2)Choose Eclipse IDE for java Developers and download it.
    3)Unzip eclipse to c:\eclipse\Basics folder
    4)Doubleclick eclipse.exe in c:\eclipse\Basics\eclipse
    5)Workspace type ./wksp/lab
    6)Download and install SVN according the instruction at
    7)Download JUnit from and unzip it to c:\junit4.9b2.
    8)Add junit-4.9b2 to the CLASSPATH, for example:
    9)Test if junit is installed correct or not by typing:
    java org.junit.runner.JUnitCore org.junit.tests.AllTests
    If it display ok (508 tests), it means junit is installed correctly.
 2. Creating your first Java project
    1)Open our SVN server and export all samples to c:\ecl500samples.
    2)Click Import->existing projects, select c:\ecl500samples\w11-basics-simple,
    check copy projects into workspace.
    3)Edit by adding System.out.println("Hello"); in main.
    4)Click run, and the console will display Hello.
 3. Browsing Java elements using the package explorer
    In the left side of Eclipse, that is the package explorer.
    Use mouse to expend cs.ecl.basics.simple, I can see src and JRE System Library.
 4. Creating a Java class
    In package explorer, right click on src folder, and select new->class,
    type student, and click enter key.
    Actually is a class, I'm going to use it as an example
    instead of
 5. Editing Java elements
    In, I use source generator added following code:
    public String toString() {
        return "Library [resources=" + resources + "]";
 6. Renaming Java elements
    I changed to by changing the interface name.
 7. Moving and copying Java elements
    I copied and paste it in the project, and changed name to Video, then is created.
    If I use mouse to move to, it's the same as copying.
 8. Navigate to a Java element's declaration
    In, I hightlight Media, the Media became gray background.
    Then I right click on Media, and select open declearation, it switch to
 9. Viewing the type Hierarchy
    In, I hightlight Media, the Media became gray background.
    Then I right click on Media, and select open type hierarchy.
    The left panel show Media as a menu, Audio, Book, Video as sub menu.
 10.Searching the workbench
    In menu, select search, a window pop up.
    I input Audio, and click search.
    At the bottom of eclipse, a window shows 1 match in workspace.
    And it showed public interface Audio extends Media{
    I click on that, it switched to
 11.Running your programs
    I changed the main in
    public static void main(String[] args) {
        Audio a = null;
        Library<Audio> La = new Library<Audio>();
    I clicked run, it shows:
 12.Debugging your programs
 13.Evaluating expressions
 14.Evaluating snippets
 15.Using the Java browsing perspective
 16.Writing and running JUnit tests