Module Road Map 1 2 3 4 5

  • Slides: 72
Download presentation
Module Road Map 1. 2. 3. 4. 5. 6. Overview Installing and Running Building

Module Road Map 1. 2. 3. 4. 5. 6. Overview Installing and Running Building and Running Java Classes Refactoring Debugging Testing with JUnit 7. Version Control with Subversion § Introduction Lecture 4 § Terminology § Adding a repository to Eclipse Workbench § Sharing a project § Checking out a project from repository § Synchronizing with respository v 1. 6 08/02/2006 1

The Problem of Version Control n Suppose two programmers are working on a project.

The Problem of Version Control n Suppose two programmers are working on a project. q (See http: //svnbook. red-bean. com/en/1. 4/svn-book. html#svn. basic) They edit the same file. q Then they both save their changes. q ; q What will happen? One approach: Programmer P 1 locks the file, then unlocks it when done. ; v 1. 6 What is wrong with this? 08/02/2006 2

Subversion (SVN) n n n An open-source based version-control system Allows coordination of source

Subversion (SVN) n n n An open-source based version-control system Allows coordination of source code changes made by individual developers working on a team Client-server method lets developers access code from anywhere there’s an internet connection. q q q Central server maintains history of all changes made to directory trees, called repositories Client machines have a copy of all files that developers are working on. The changes are then reported to the central server using a client that can access and update repositories. v 1. 6 08/02/2006 3

Subversion — What it does n Subversion operations q Checking out from a repository

Subversion — What it does n Subversion operations q Checking out from a repository ; q Sharing a resource ; q Retrieves a directory from a Subversion repository to the Workbench on local machine Creates a copy of the resource on the Subversion repository Synchronizing with a repository ; Update n ; Commit n v 1. 6 Before you can commit changes, Subversion requires your sources to be in sync with any changes committed by other developers. To make the changes available to other developers, you must commit them to the repository. 08/02/2006 4

Download Subversion v 1. 6 08/02/2006 5

Download Subversion v 1. 6 08/02/2006 5

Installing Subversion I chose the latest stable version of Windows binary v 1. 6

Installing Subversion I chose the latest stable version of Windows binary v 1. 6 08/02/2006 6

Unzipping Subversion v 1. 6 08/02/2006 7

Unzipping Subversion v 1. 6 08/02/2006 7

Put Subversion in C: Program Files v 1. 6 08/02/2006 8

Put Subversion in C: Program Files v 1. 6 08/02/2006 8

Install Subversive, the Eclipse Client v 1. 6 08/02/2006 9

Install Subversive, the Eclipse Client v 1. 6 08/02/2006 9

Installing Subversive In Eclipse: Help > Software Upates > Find and Install v 1.

Installing Subversive In Eclipse: Help > Software Upates > Find and Install v 1. 6 08/02/2006 10

Search for Features of New Plug-in v 1. 6 08/02/2006 11

Search for Features of New Plug-in v 1. 6 08/02/2006 11

Select New Remote Site v 1. 6 08/02/2006 12

Select New Remote Site v 1. 6 08/02/2006 12

Fill in the Dialog Box n n n On the New Update Site dialog

Fill in the Dialog Box n n n On the New Update Site dialog enter the name of the update site and URL. Use the following values: n. Name: Subversive n. URL: for Subversive 1. 1. x: http: //www. polarion. org/projects/subversive/download/1. 1 /update-site/ for Subversive 1. 0. x: http: //www. polarion. org/projects/subversive/download/up date-site/ Click on the OK button to store update site information. v 1. 6 08/02/2006 13

Select Subversive n v 1. 6 08/02/2006 14 To start searching the update sites,

Select Subversive n v 1. 6 08/02/2006 14 To start searching the update sites, select Subversive and click on the Finish button.

Installing Subversive Features n n You will then be asked to select the features

Installing Subversive Features n n You will then be asked to select the features to install. It is safe to install features. (If you want to save disk space, see the discussion at http: //www. polarion. org/ind ex. php? page=installation& project=subversive#notes v 1. 6 08/02/2006 15

License Agreement n Accept the terms of the license agreement. v 1. 6 08/02/2006

License Agreement n Accept the terms of the license agreement. v 1. 6 08/02/2006 16

Install Features n Then install the features. v 1. 6 08/02/2006 17

Install Features n Then install the features. v 1. 6 08/02/2006 17

Install Features, cont. n Install the feature, despite the warning. v 1. 6 08/02/2006

Install Features, cont. n Install the feature, despite the warning. v 1. 6 08/02/2006 18

Restart for Safety n I suggest you restart Eclipse v 1. 6 08/02/2006 19

Restart for Safety n I suggest you restart Eclipse v 1. 6 08/02/2006 19

Configure Subversive n After installation, choose Help > Software Upgrades > Manage Configuration v

Configure Subversive n After installation, choose Help > Software Upgrades > Manage Configuration v 1. 6 08/02/2006 20

Select Subversive Team Provider n Click to open “Eclipse SDK”; then select SVN Team

Select Subversive Team Provider n Click to open “Eclipse SDK”; then select SVN Team Provider. v 1. 6 08/02/2006 21

Connecting with Subversive n Select Window > Open perspective > Other v 1. 6

Connecting with Subversive n Select Window > Open perspective > Other v 1. 6 08/02/2006 22

Select “Subversion Repository Exploring” v 1. 6 08/02/2006 23

Select “Subversion Repository Exploring” v 1. 6 08/02/2006 23

Click “New Repository Location” v 1. 6 08/02/2006 24

Click “New Repository Location” v 1. 6 08/02/2006 24

Select a Repository n Give the URL, user-ID, and password, then click “Finish”. v

Select a Repository n Give the URL, user-ID, and password, then click “Finish”. v 1. 6 08/02/2006 25

Expand the Repository Click on the name of the repository to expand it v

Expand the Repository Click on the name of the repository to expand it v 1. 6 08/02/2006 26

Check out the Project n Right-click on the name of the project to check

Check out the Project n Right-click on the name of the project to check it out. v 1. 6 08/02/2006 27

Project Checked Out The project at the top of the pane was checked out.

Project Checked Out The project at the top of the pane was checked out. v 1. 6 08/02/2006 28

Modify a Class v 1. 6 08/02/2006 29

Modify a Class v 1. 6 08/02/2006 29

Committing Changes Save the file, then right-click on the filename and choose Team >

Committing Changes Save the file, then right-click on the filename and choose Team > Commit v 1. 6 08/02/2006 30

Subversion n A conflict occurs when q q you have locally modified a resource

Subversion n A conflict occurs when q q you have locally modified a resource for which a more recent revision is available ; n » Conflicts in the branch in the repository. 3 methods to resolve conflicts: q Discard local copy by overwriting it with the newer version on the repository. q Overwrite the copy on the repository with the local copy. ; q Use extreme caution since you will be erasing changes made by others. Merge your work and the repository resource, saving locally the merged resource. v 1. 6 08/02/2006 31

CVS n » Conflicts Conflict types: q An auto-mergeable conflicting change occurs when an

CVS n » Conflicts Conflict types: q An auto-mergeable conflicting change occurs when an source-code file ; ; q has been changed both remotely and locally (i. e. has noncommitted local changes) but the changes are in different lines. A non-auto-mergeable conflicting change occurs when ; ; one or more of the same lines of a source-code file have been changed or when a binary file has been changed both remotely and locally. n v 1. 6 Binary files are never auto-mergeable. 08/02/2006 32

Introduction to Net. Beans v 5. 0 Integrated Development Environment v 1. 6 08/02/2006

Introduction to Net. Beans v 5. 0 Integrated Development Environment v 1. 6 08/02/2006

Lecture Overview n n n Net. Beans Overview Installing and Running Net. Beans Projects

Lecture Overview n n n Net. Beans Overview Installing and Running Net. Beans Projects Building and Running Java Classes Building Running Web Applications Refactoring Applications v 1. 6 08/02/2006 34

Lecture Road Map n Net. Beans Overview Introduction to Net. Beans q Features q

Lecture Road Map n Net. Beans Overview Introduction to Net. Beans q Features q n n n Net. Beans Projects Installing and Running Net. Beans Building and Running Java Classes Building and Running Web Applications Refactoring Applications v 1. 6 08/02/2006 35

Net. Beans Overview » Introduction to Net. Beans n n A comprehensive, modular Java-based

Net. Beans Overview » Introduction to Net. Beans n n A comprehensive, modular Java-based IDE (Integrated Development Environment). Free and open-source based. q q n n Open source since June 2000 Large community of users and developers Provides a platform for building rich-client Java applications, Web services etc. Supports plug-in architecture. Large set of third-party modules (plugin’s) are included in the downloadable version. v 1. 6 08/02/2006 36

Net. Beans Overview » Features n Ant-based project system q q q n n

Net. Beans Overview » Features n Ant-based project system q q q n n Apache Ant is a Java-based build tool used to standardize and automate build and run environments for development. It is not necessary to know Ant to work with the IDE. See http: //ant. apache. org/resources. html for more information on Ant. Matisse GUI Builder - provides rich framework of windows, menus, toolbars and actions. Plug-in (module) and rich client application development wizard. CVS version control. Enhanced Refactoring. v 1. 6 08/02/2006 37

Net. Beans Overview » Features n Enterprise Development q n Developer Collaboration q q

Net. Beans Overview » Features n Enterprise Development q n Developer Collaboration q q n JBoss 4 and Weblogic 9 Support. Discuss/share code with other developers remotely. Conduct code review using chat capabilities. Allow others to make changes which are then represented to the rest of the group via visual cues. Send messages in plain text, XML, HTML, or Java code format. Application Profiling q q CPU performance profiling Memory profiling and memory leak detection v 1. 6 08/02/2006 38

Lecture Road Map n n Net. Beans Overview Installing and Running q q q

Lecture Road Map n n Net. Beans Overview Installing and Running q q q n n Where to get Net. Beans? Installing Net. Beans Running Net. Beans Projects Building and Running Java Classes Building and Running Web Applications Refactoring Applications v 1. 6 08/02/2006 39

Installing and Running Net. Beans » Where to get Net. Beans ? n n

Installing and Running Net. Beans » Where to get Net. Beans ? n n http: // www. netbeans. org provides downloads, articles and tutorials related to Net. Beans. IDE can be downloaded from http: //www. netbeans. info/downloads/index. php v 1. 6 08/02/2006 40

Installing and Running Net. Beans » Installing Net. Beans n n n Net. Beans

Installing and Running Net. Beans » Installing Net. Beans n n n Net. Beans is available for Windows, Mac. OS, Linux and Solaris operating systems. Choose the Net. Beans IDE 5. 5. 1 installer for the operating system that is installed on your development system. For Windows operating system, download the IDE 5. 5. 1 installer ‘netbeans-5_5_1 -windows. exe’. Prior to Net. Beans installation, make sure JVM (Java Virtual Machine) is installed. It is recommended that JDK 5. 0 be downloaded from http: //java. sun. com/j 2 se/1. 5. 0/download. jsp and installed. Execute the Net. Beans self-extracting installer to start Net. Beans installation. Follow the install shield instructions. v 1. 6 08/02/2006 41

Installing and Running Net. Beans » Running Net. Beans n On Windows XP, choose

Installing and Running Net. Beans » Running Net. Beans n On Windows XP, choose Start » All Programs » Net. Beans 5. 0 » Net. Beans IDE to launch Net. Beans IDE. v 1. 6 08/02/2006 42

Lecture Road Map n n n Net. Beans Overview Installing and Running Net. Beans

Lecture Road Map n n n Net. Beans Overview Installing and Running Net. Beans Projects q q n n n About Projects Project Templates Building and Running Java Applications Building and Running Web Applications Refactoring Applications v 1. 6 08/02/2006 43

Net. Beans Projects » About Projects n n n A project is a group

Net. Beans Projects » About Projects n n n A project is a group of source files and the settings with which you build, run, and debug those source files. The Net. Beans IDE stores all of the information about a project in an Ant script, a properties file, and a few XML configuration files. The IDE includes support for two types of projects: q q Standard Projects: The IDE uses a Net. Beans-generated Ant build script to build, run, clean, test, and debug your application. Free-form Projects: The IDE uses targets in an existing Ant script to build, run, clean, test, and debug your application. v 1. 6 08/02/2006 44

Net. Beans Projects » Project Templates n n n The IDE includes several project

Net. Beans Projects » Project Templates n n n The IDE includes several project templates designed to support different types of development including Web applications, general Java applications, and so forth. Standard Templates: The IDE controls all source and classpath settings, compilation, running, and debugging. The IDE generates an Ant script in which all project settings are stored. q Standard Java Applications: Java Application, Java Class Library, Java Project with Existing Sources. q Web Applications: Web Application, Web Application with Existing Sources. q Enterprise Applications: Enterprise Application, Enterprise Application with Existing Sources. q EJB Modules: EJB Module, EJB Module with Existing Sources q Net. Beans Plug-in Modules: Module Project, Module Suite Project, Library Wrapper Module Project. Free-Form Project Templates: The IDE relies on an existing Ant script for instructions on how to compile, run, and debug applications. q Java Project with Existing Ant Script: A free-form Java project. q Web Project with Existing Ant Script: A free-form project containing a web application. q EJB Module with Existing Ant Script: A free-form project containing an Enterprise Java. Beans module. v 1. 6 08/02/2006 45

Lecture Road Map n n Net. Beans Overview Installing and Running Net. Beans Projects

Lecture Road Map n n Net. Beans Overview Installing and Running Net. Beans Projects Building and Running Java Applications ; ; n n Setting up a Project Creating and Editing Java Source Code Compiling, Running and Debugging a Project Testing with JUnit Building and Running Web Applications Refactoring Applications v 1. 6 08/02/2006 46

Java Applications » Setting up a New Project n n From the main menu,

Java Applications » Setting up a New Project n n From the main menu, choose File » New Project. This opens up the New Project window. In Categories pane, select General. In Projects pane, select Java Application and click Next. v 1. 6 08/02/2006 47

Java Applications » Setting up a New Project n n Enter the name of

Java Applications » Setting up a New Project n n Enter the name of the project in the Project Name text box. Choose a folder for the Project Location. Ensure that Set as Main Project and Create Main Class checkboxes are checked. Enter the fully qualified name of the main class (without the. java extension) in the text box adjacent to the Create Main Class checkbox. The class name may be qualified with a package name and a dot (for example, mypackage. Main. Class). n Click Finish. v 1. 6 08/02/2006 48

Java Applications » Setting up a New Project n n n The project will

Java Applications » Setting up a New Project n n n The project will be displayed in the Projects window. The Java file that contains the skeleton code for the main class opens in the Source Editor. Expand the project name (a. k. a. project node) in the Projects window to view the Java files that belong to the project. v 1. 6 08/02/2006 49

Java Applications » Setting up a New Project n Click on the Files tab

Java Applications » Setting up a New Project n Click on the Files tab to view the project’s file structure in the Files window. v 1. 6 08/02/2006 50

Java Applications » Setting up a New Project » Project Properties n n n

Java Applications » Setting up a New Project » Project Properties n n n Right-click on the Project node in the Projects window. This will open the Project Properties window. In Categories pane, click on Libraries. Click Manage Platforms button to specify a different JDK platform. Compile-time and run-time class paths may be specified using the Compile tab and the Run tab respectively. v 1. 6 08/02/2006 51

Exercise 1 n Create a New Java Application Project titled Eg. App with a

Exercise 1 n Create a New Java Application Project titled Eg. App with a main class titled Main. Class in a new package titled csc 517. v 1. 6 08/02/2006 52

Lecture Road Map n n Net. Beans Overview Installing and Running Net. Beans Projects

Lecture Road Map n n Net. Beans Overview Installing and Running Net. Beans Projects Building and Running Java Applications ; ; n n Setting up a Project Creating and Editing Java Code Compiling, Running and Debugging a Project Testing with JUnit Building and Running Web Applications Refactoring Applications v 1. 6 08/02/2006 53

Java Applications » Creating and Editing Java code n In this module, you will

Java Applications » Creating and Editing Java code n In this module, you will learn how to Create a new class q Navigate a Project node q Add a new method to a class q Create a new field to a class q Use editing shortcuts q v 1. 6 08/02/2006 54

Java Applications » Creating and Editing Java code » Creating a new Java class

Java Applications » Creating and Editing Java code » Creating a new Java class n n n To create a new Java class, right-click on the project node in the Projects window and choose New » Java class. The New Java Class window will be displayed. Enter the name of the new Java class in the Class Name text box. If the new class needs to be part of a package, type the name of a new package in the Package text box or choose an existing package from the drop-down list. Click Finish. The IDE generates the skeleton source code of the new Java class and opens it up in a new Java source window. v 1. 6 08/02/2006 55

Java Applications » Creating and Editing Java code » Navigating the project node n

Java Applications » Creating and Editing Java code » Navigating the project node n n In the Projects window, expand Source packages node under the Project node to view the package nodes and Java file nodes. Expand the Java file node to view the classes defined in the Java file. Double-click on the Java file to open the Java file in the Source editor. Expand the class node to view the fields, constructors and methods of the class. v 1. 6 08/02/2006 56

Java Applications » Creating and Editing Java code » Adding a new method to

Java Applications » Creating and Editing Java code » Adding a new method to a class n n n Right-click on the Methods node of the class and click Add Method to create a new Java method. This opens up the Add New Method window. The Name, Return Type, Access, Modifiers and Parameters of the new method may be specified in the Add New Method window. v 1. 6 08/02/2006 57

Java Applications » Creating and Editing Java code » Adding a new field to

Java Applications » Creating and Editing Java code » Adding a new field to a class n n n Right-click on the Fields node of the class and click Add Field to add a new field. This opens up the Add New Field window. The Name, Type, Access, Modifiers and Initial Value of the field may be specified in the Add New Field window. v 1. 6 08/02/2006 58

Java Applications » Creating and Editing Java Source Editing Shortcuts: q q Ctrl+Shift+F: Reformat

Java Applications » Creating and Editing Java Source Editing Shortcuts: q q Ctrl+Shift+F: Reformat the whole source code window. Ctrl+Space: Code-completion box. (The IDE offers code completion for all classes and methods in the project's compilation classpath). v 1. 6 08/02/2006 59

Exercise 2 n n n Create a new class titled New. Class and add

Exercise 2 n n n Create a new class titled New. Class and add it to the package csc 517 in the project Eg. App you have created in Exercise 1. Add a private integer field (member variable) m. Var to the class New. Class. Change the default constructor to accept integer parameter to initialize the private integer field m. Var. Add a public method print. Field that takes no parameters and returns void. Add code to the print. Field method to print the value of the private variable m. Var to standard output. (Hint: To use code-completion feature for the print routine, type “sys” and hit Ctrl-Space. The IDE pops-up the code completion box with a list of methods. Choose System. out. println() print routine). v 1. 6 08/02/2006 60

Lecture Road Map n n n Net. Beans Overview Installing and Running Net. Beans

Lecture Road Map n n n Net. Beans Overview Installing and Running Net. Beans Projects Refactoring Applications Building and Running Java Applications ; ; n Setting up a Project Creating and Editing Java Source Code Compiling, Running and Debugging a Project Testing with JUnit Building and Running Web Applications v 1. 6 08/02/2006 61

Java Applications » Compiling, Running and Debugging a project n In this module, you

Java Applications » Compiling, Running and Debugging a project n In this module, you will learn how to Build a Java project q Run a Java project q Debug a Java project q v 1. 6 08/02/2006 62

Java Applications » Compiling, Running and Debugging a Project » Building Project n n

Java Applications » Compiling, Running and Debugging a Project » Building Project n n Choose Build » Build Main Project (F 11) from the main menu to build (compile) a project. Choose Build » Clean and Build Main Project (Shift+F 11) from the main menu to clean and build a project Alternatively, right-click on the project node in the project window and click Build Project or Clean and Build Project from the contextual menu. The Output window displays the build results. v 1. 6 08/02/2006 63 a

Java Applications » Compiling, Running and Debugging a Project » Running Project n n

Java Applications » Compiling, Running and Debugging a Project » Running Project n n n Choose Run » Run Main Project (F 6) from the main menu to run a project. Alternatively, right-click on the project node in the Project window and click Run Project from the contextual menu. The Output window displays the project output. v 1. 6 08/02/2006 64 a

Java Applications » Compiling, Running and Debugging a project » Debugging project n n

Java Applications » Compiling, Running and Debugging a project » Debugging project n n n To set a breakpoint, place the caret in any of the methods in the Java file and press Ctrl+F 8. The selected line will be highlighted indicating that the breakpoint has been set. Choose Run » Debug Main Project (F 5) from the main menu to debug the project. The IDE runs the project in the debugger until the breakpoint is reached. The IDE open the Debugger windows at the bottom of the IDE. v 1. 6 08/02/2006 65 a

Java Applications » Compiling, Running and Debugging a Project » Debugging a Project n

Java Applications » Compiling, Running and Debugging a Project » Debugging a Project n n To step over a line of code, choose Run » Step Over (F 8) from the main menu. To step into a method, choose Run » Step Into (F 7) from the main menu. To step out of a method, choose Run » Step Out (Ctrl + F 7) from the main menu. To terminate a debugging session, choose Run » Finish Debugger Session (Shift+F 5). v 1. 6 08/02/2006 66

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n n

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n n The Local Variables, Watches, and Call Stack windows open by default with every debugging session. You can open any debugger window by choosing Window » Debugging » window-name (for example, Window » Debugging » Breakpoints). v 1. 6 08/02/2006 67

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Local

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Local Variables Window q q q n The Local Variables window lists the local variables in the current call. The information given for each variable includes the variable name, type, and value. You can click the control to the left of the name to expand or collapse the variable. Call Stack Window q q The Call Stack window lists the sequence of calls made during execution of the current thread. The information given for each call includes the name of the method, followed by the filename and line number of the call's currently executing statement. v 1. 6 08/02/2006 68

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Watches

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Watches Window q q q The Watches window lists all variables and expressions that you have specified to watch while debugging. The information given for each watch includes the variable or expression name, type, and value. When you add a new variable or expression to the Watches window, the value of the variable or expression is immediately evaluated and displayed. The value of a watch is based on the current context. As you move through your program code, the Watches window is updated to show the value of the watch for that context. Creating a Watch: ; ; ; v 1. 6 Select the variable or expression in the Source Editor, right-click, and choose New Watch (Ctrl+Shift+F 7). The New Watch dialog box opens with the variable or expression entered in the text field. Click OK. The Watches window opens with the new watch selected. 08/02/2006 69

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Classes

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Classes Window q q q n The Classes window displays the hierarchy of all classes that have been loaded into the virtual machine hosting the program that is being debugged. You can click the turner control (+) to the left of the class name to expand or collapse the class. You can inspect the fields, constructors, and methods in your program as well as inspect the value of static variables. Breakpoints Window q q The Breakpoints window lists the breakpoints set in the current project. By default, each entry contains a short text description of the breakpoint and a boolean flag indicating whether the breakpoint is enabled or disabled. v 1. 6 08/02/2006 70

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Session

Java Applications » Compiling, Running and Debugging a Project » Debugger Windows n Session Window q q n The Sessions window lists the debugging sessions currently running in the IDE. The information given for each session includes the session name and state. One session is always considered the current session, unless no sessions are running. By default, the current session is the session that you most recently started. Threads Window q q q The Threads window lists all threads in the current debugging session. For Java applications, this list also includes the thread groups in the Java virtual machine. The information given for each thread is the thread name and state. v 1. 6 08/02/2006 71

Exercise 3 n n In the project Eg. App, based on the class New.

Exercise 3 n n In the project Eg. App, based on the class New. Class that was created in Exercise 2, instantiate an object of type New. Class in the main() routine of the Main. Class. Call the print. Field routine of the New. Class object. (Use the code-completion feature of the IDE. ) n Build (compile) the project Eg. App. n Run the project Eg. App. n What do you see in the output window ? v 1. 6 08/02/2006 72