Java and project delivery
1 / 21

Java and Project Delivery - PowerPoint PPT Presentation

  • Uploaded on

Java and Project Delivery. E&CE 250 Winter 2002. We are using the Java 2 Version 1.3 SDK java -version It provides the following tools:. Java on Polaris. javac java javadoc jar jdb

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Java and Project Delivery' - tracy

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Java and project delivery

Java and Project Delivery

E&CE 250

Winter 2002

Java on polaris

We are using the Java 2 Version 1.3 SDKjava -version

It provides the following tools:

Java on Polaris







The compiler for the Java programming language

The launcher for Java applications

API document generation

Creation and management of Java Archive files

The Java Debugger

The launcher for Java applets

Setting up
Setting up

1. Log onto Polaris

2. Open the MS-DOS prompt from Windows

3. Create a ece250 directory in n:\

n:\ mkdir ece250

4. Edit n:\privexec.bat and add the lines:

set PATH=%PATH%;q:\eng\ece\jdk1.3\bin

set CLASSPATH = N:\ece250

5. Run the batch file n:\privexec.bat again

Java program stringoperations
Java program: StringOperations

  • Use any text editor you like

  • Enter the following program:

public class StringOperations {

public static void main (String[] args) {

String str = “If there were dreams to sell, What would you buy?”;

System.out.println (“The string is: ” + str);

System.out.println (“The length is: ” + str.length());

System.out.println (“Substring 14-20: ” + str.substring(14,20));

System.out.println (“Uppercase is: ” + str.toUpperCase());



  • Save the program as in your n:\ece250 directory

Compile the program
Compile the program

  • Open the MS-DOS prompt and change your directory:n:\> cd ece250

  • Now compile the program:n:\ece250> javac

  • If everything works, you’ll get no messages back

  • Check to see if a StringOperations.class file has been created. n:\ece250> dir *.class

Note: For a Java program to compile properly, the name of the file and class defined must be the same. Remember: file name = class name.

Run the program
Run the program

  • Now run the program:n:\ece250> java StringOperations

    If it works, you’ll see:The string is: If there were dreams to sell, What would you buy?

    The length is: 49

    Substring 14-20: dreams


  • If it fails, you’ll probably see:

    Exception in thread “main”



    This will happen if you forgot to set the classpath to include your working directory.


  • A brief introduction to javadoc:

    • The purpose of this tool is to automatically generate HTML documentation from your .java source files.

    • You can run Javadoc on individual .java files, or .jar files

    • A comment must be added before the section it is commenting


  • The documentation is created by adding special tags in your .java files. These tags enable you to document your source code.

  • The tags start with an "at" sign (@) and are case-sensitive (they must be typed with the lowercase letters as shown)

  • Some common tags are:





javadoc Example


* The StringOperations class represents manipulation of strings

* @author Ricardo Rolon

* @version 1.0, Sep 2001


public class StringOperations {


* Creates a String object.


public static void main (String[] args) {

String str = “If there were dreams to sell, What would you buy?”;

System.out.println (“The string is: ” + str);

System.out.println (“The length is: “ + str.length());

System.out.println (“Substring 14-20: “+ str.substring(14,20));

System.out.println (“Uppercase is: “ + str.toUpperCase());



Javadoc -author -version

Jar files
Jar files

  • The jar tool allows you to create archives, similar to a .zip archive. (In fact, they are based on ZIP compression)

  • There are several reasons we want to do this:

    • easier to transfer (compressed files = less time over a network)

    • easier to execute (all the .class files are in the .jar, makes only one connection to the server)

    • jar’s can besigned by the author (security)

    • can store additional files like .html, readmes, etc.

Jar files1
Jar files

Example: jar cvmf myManifestFile myJarFile *.class *.html *.java

Where c option indicates that a jar file must be created,

v means to be Verbose

m include my own Manifest file

fput the .jar file in a separate File whose name is provided

The Java Virtual Machine needs to know which .class file in the .jar file contains the main( ) method. To do that, create a text file with just one line:

Main-Class: <MainJavaClass>

For instance, in Project 1, if Rational.class is the class that contains main(), then MyManifestFile should contain the following line:

Main-Class: Rational

Don’t forget to end the Main-Class line with a carriage return, otherwise jar will not recognize it.

Jdb java debugger http java sun com j2se 1 3 docs tooldocs win32 jdb html
jdb (java debugger)

  • Compile the program with the -g option (extra class info)

  • Start jdb java debugger

  • Set breakpoints

  • Run program

  • Experiment with debugger commands:

    • list -- Displays the source code of the line and several lines around it

    • locals -- List the values of local variables that are currently in use

    • print <item> -- Display the value of the variable, object, array

    • step -- Executes the next line and stops again

    • cont -- Continues running the program

    • !! -- repeats the previous debugger command.

  • After debugging the program, recompile the program without the -g option.

jdb --A debugging example

1. Compile the program: javac -g

2. Start the debugger: jdb StrigOperations

3. Set breakpoints:

stop in StringOperations.main

stop at StringOperations:15

4. Run program: run StringOperations

5. Extract debugging info with commands:

list, locals, print, step, cont

6. Recompile the program: javac

Free java tools
Free Java Tools

  • JBuilder, Borland.

  • VisualAge for Java, IBM.

  • Forte for Java (,Sun Microsystems. JCreator, JEditor, etc.

  • No native methods!!

    Keep this in mind:

    We have to be able to compile it and run it on the Java 2 SDK 1.3 platform

Vector http webobjects uwaterloo ca

  • Vector is a web-based application course administration

  • E&CE 250 will use Vector for the following:

    • Tracking of your marks for Projects

    • Electronic submission of your Projects

  • Every student in this course has an account in Vector.

  • Use your Polaris userid to login, and your ID # as your initial password.

  • Change your password immediately.

Submitting files with vector
Submitting files with Vector

  • Project 1-3

    • individual submission, under studentID

  • Project 4

    • group submission, under groupID[even if group of one student]

Project 1 3 naming of jar files
Project 1-3: Naming of .jar files

  • Name the file as your numeric Student id followed by pn where n is the project number. (That is, just 12345678p1.jar)

  • In Vector, the file name will be prep ended by your Polaris account

  • For example:If your Polaris userid is “student1” then this will upload the file as student1_12345678p1.jar

Project 4 naming of jar files
Project 4: Naming of .jar files

  • Send email to ece250 with group membership by signup due date (even if group of 1). You will get your GroupID by email.

  • Name the file as your GroupID followed by p4 where n is the project number. (If the GroupID is E250G007, use E250G007p4.jar)

  • In Vector, the file name will be prepended by your GroupID

  • For the above example, the file will be uploaded as E250G007_E250G007p4.jar


  • Please post common questions on the ECE 250 newsgroup

  • You can also send us email, phone us, or drop by during office hours

  • Make sure you give yourself lots of time.