Rather than waste connection time reading this stop press it might be worth saving it to a file using your browser.
The course maintains an email mailing list for each of its presentations, and we strongly recommend that students subscribe to this list. We use it to send notification of Web site updates and other news. Once you register for the course, you will have access to the web site for your course presentation, and you will be able to subscribe to the list from the Stop Press page.
There are two sets of errata on the course: serious errata and typos.
All the TMAs in the course involve you carrying out a large amount of programming. We ask you to supply a machine readable version of your code together with a printout of the code and any associated HTML files. The preferred method for doing this is by sending the code on a floppy disk together with the printout and your PT3. We are also happy for you to send your code via email. However, it is worth making a number of points about this:
If you register for the electronic version of this course, MZX874, you should follow the instructions in 'Using the Electronic TMAs System' which you will receive in the second mailing of course materials. You may submit your eTMAs to the eTMA Web site or to the eTMA email address.
Please note that you will need to submit:
- Your code files set out in directory structure specified in the TMAs on this Web site.
- A text file containing all the code which will be marked by your tutor using the electronic marking tool. The marking tool cannot be used with the Java files.
Sun, the developers of the Java language have developed a Professional Certification Scheme for programmers with a knowledge of Java.
The course team have examined the 55 examination objectives for the certification and are confident that most of these are satisfied by the study of M868 and M874. The objectives that we feel you need to read further on and practice via programming are the six below:
There are a number of sites maintained by individuals which contain the latest Java trawlings from the Web, pointers to tools, tutorials and articles. A selection is shown below:
There are a number of directories which contain lists of Java resources. These are listed below:
A number of tutorials on Java have been set up. A list of these is shown below:
There are a number of independent book listings which have been set up. Three are listed below. The last one provides a navigable way to find your way through the large number of Java books that have been published.
If you are accessing this web site from your work and your system administrator has erected a firewall or similar device around your network to prevent applets being read into your browser, then you will find that you will not be able to access the computer mediated questions. Currently there are only two solutions to this: either persuade your system administrator to modify the policy (admittedly unlikely) or try and access the Web site from an unconstrained browser.
Before starting the course it is worth checking that the installation of the Java system has worked. First check that the MSDOS command line window points to your M874Programs folder. You will see this on the prompt line in the window. If you do not see it you will have to carry out the following procedure:
After you have done this check that your system recognises the Java system software. All you need do is to type the line Java to the MSDOS prompt and you will see a long multi-line message starting with a line which commences with usage Java. if you see this line then everything is fine. If not you will have to carry out the following procedure:
The CCI programme organises short schools on each course in the programme. These are held at a number of university locations around the country. They normally take place towards the end of a course and provide an excellent opportunity for revision. We are providing a package of material for tutors who will be teaching at M874 schools. . Tutors will base their sessions on the material that we have produced; however, we are giving them the freedom to modify the materials as they see fit.
The package will contain:
A set of Powerpoint slides which cover the main topics of the course.
A set of exercises in the same format as that found on the course CD.
A sample examination paper different to the one which is provided for you in the course mailing, together with a set of slides which take you through the answers to the paper.
You can download the slides to your own computer if you have Powerpoint installed. This is not an official part of the course, so regard it as an add-on. You can download:
A plain white background version (395kb) of the slides and notes.Load this if you do not have unzip facilities.
A glitzy version (400kb). You can play this as a slide show and use the notes as, say, revision. Load this if you do not have unzip facilities.
A zip file of both version (166kb) of the slides and notes.
The exam presentation consists of around 45 Powerpoint slides which look at typical examination questions and answers. There are two versions of these slides. If you have unzipping facilities then there is a zipped version (19kb). If you do not have zipping facilities then there is a raw version (90kb).
We are grateful to Robin Thomson, a tutor on the course, for the information that a free Powerpoint viewer can be downloaded fromMicrosoft. You can use this to view the slides for the two-day school presentation and also the slides for the two day school session on the M874 examination.
The Pfe32 editor contains a facility whereby you can, within the editor, bring up a DOS command line and execute it. You might find this useful when editing and compiling a Java program. The Execute menu contains a DOS command to Window item (F11) as its first pull down. When you activate this item it will ask you for the name of the command. Type in java followed by the name of the file you are currently editing. In the same dialog you will need to change the directory that the editor points to to M874Programs. After this all you need to do to syntax check and compile a file is to activate the Execute menu and pull down and release the Repeat DOS Command to Window item.The output from the command will appear as a window in your editor.
Some students have asked about their use of IDEs such as Visual J++ and Symantec Cafe. We have no objection to their being used. The only point that we would want to make is that they use absolute layout schemes to layout the widgets of an interface. We want you to use the portable layout managers such as GridLayout in your work and, in particular, in your TMA answers. Most IDEs allow you to switch into these layout mangers so there should be no problems.there is alos a further problem with Visual J++ as it only uses the java 1.0 event model and we use the 1.1 event model on the course.
Some of you may not understand this point until later in the course when we deal with HCI, it is worth filing this note away until then.
There have been a number of student questions about the use of this. When this is used outside a constructor it is normally used to refer to the instance variables within the destination object. For example, if you had a class which had two instance variables x and y and you had a line of code in a method which referred to them, say in assigning some values to them as in
x = 2; y =3;
then this is equivalent to writing
this.x = 2; this.y = 3;
In this context this refers to this destination object. Normally unless we want to explicitly draw attention to the fact we are referring to the instance variable we omit the this.
There seems to be a little haziness about the difference between = = and equals. The former can be used to compare scalars or objects. When it is used to compare scalars it carries out a comparison on their values, when it is used to compare objects it compares addresses. The method equals is used to compare the equality of objects. All the classes in the Java API have equals already defined. However, if you have developed a new class and need to carry out some equality comparison of the values of objects defined by the class then you will need to define a method equals for that class. Normally the code for this method carries out some element-by-element equality comparison of the instance variables: for instance variables that are objects then an equals message is sent to them and for scalars = = is used. Not understanding the difference between = = and equals leads to some very subtle programming errors, so be awake.
There is a possible problem with the Netscape browser and these two exercises. In exercise 2.10 you are asked to click on the top-level documentation. This link may not work in Netscape. In exercise 3.4 you are asked to click on the Top page of the Java documentation and on index, these links may not work.The best solution is to use your browser to open the file java/api/packages.html in the JDK version that we sent you and to add this link to the favorites collection for your browser.
Whenever a new version of Java is developed the browser manufacturers take their time in catching up. This slightly affects the exercises in the course which ask you to develop applets: snippets of HTML which contain Java code. Currently Internet Explorer 4.0 is 99.99 percent compatible with Java and Netscape 4.04 onwards is compatible with a patch which can be obtained from the Netscape site. If you want details on upgrading your browser to Java 1.1 then a tip in Java World provides this information. If you do not want to upgrade, then the JDK 1.1 kit supplied with the course has a program known as the appletviewer. This is initiated by using the MSDOS line and referencing the html file containing the applet. What this program does is to strip off all the html code from the file and just executes the applet in the file. The pages which are provided for you on the course CD and on this Web site can be accessed by any Java 1.0 compliant browser.
In each of the TMAs we stress that whatever version of Java you use, or whether you use an IDE, you should compile and run your Java code using the JDK version supplied with the course and check that it works. If you don't and your code does not run on your tutor's machine then you will be penalised.
TMA03 requires you to develop a server and a client which interact with each other. In order to do this they use sockets and server sockets which are based on the TCP/IP protocol. It is worth checking that your system can handle this form of communication. In order to do this we have provided you with two programs. The first is a simple client which sends a single test string to the second program which is a server. The server reads the test string and then displays it on the MSDOS line, it will sleep for five seconds and then return you to the MSDOS command line. We have built in this delay in case some of you are using an Integrated Development Environment (IDE) which collapses the MSDOS window when execution finishes preventing you from reading the output.
The tasks that you should carry out to check everything is working for TMA03 are:
The programs are shown below, as well as checking your system they provide you with examples of the two streams that it is best to use for client, server communication: BufferedReader and PrintWriter. The server is:
import java.net.*;
import java.io.*;
public class SimpleServer {
public static void main(String args[]) {
Socket s=null;
ServerSocket ss=null;
BufferedReader br = null;
try{
ss = new ServerSocket(1024);
//Blocks waiting for the client
System.out.println("Server started waiting for client");
s = ss.accept();
br = new BufferedReader(new InputStreamReader(s.getInputStream()));
System.out.println(br.readLine());
//Code below sleeps for 5 seconds
//just in case student uses an IDE which destroys
//the MSDOS window automatically
System.out.println("5 seconds to finish");
try{
Thread.sleep(5000);
}
catch(Exception e){};
s.close();
ss.close();
br.close();
}
catch(IOException iExc){
//You have a problem
System.out.println("Problem with connection");
iExc.printStackTrace();
}
}
}
The client is
import java.net.*;
import java.io.*;
public class SimpleClient {
static public void main(String args[]) {
Socket s = null;
PrintWriter ps = null;
try{
s = new Socket("127.0.0.1", 1024);
ps = new PrintWriter(s.getOutputStream(), true);
//true ensures autoflushing
ps.println("Test message sent OK");
ps.close();
s.close();
}
catch(IOException iExc){
System.out.println("Problem with client connection");
iExc.printStackTrace();
}
}
}