Recent Changes - Search:

Java Tutorial

edit SideBar

ACompleteDiversion

These pages make up the course notes for my Java programming course (run at Dallam, Milnthorpe, Cumbria). Hopefully they also make a useful self-learning tutorial.

A complete diversion
(in theory there is no difference between theory and practice)

In the previous section we looked a basic program. But how do we get this work? Like the recipe for making tea given in the previous section it is easy to discuss the theory but to make tea we need a kettle (or some other means of heating water), a water supply, a supply of tea bags and milk … The practicalities of doing a job are very often much more complicated than the instructions would suggest.

We need a certain level of general skills to be an effective programmer. Here are some things you really ought to learn about (if you don't know them already) to help with programming and with the rest of this tutorial.

  • How to find, open and delete files in the file system (e.g. using Windows Explorer)
  • How to create a text file using a text editor and save it in a specific location (e.g. using Notepad)
  • Understand the importance of file extensions and how to associate files of a given type with an application
  • How to work effectively from the command prompt (see CommandLineJava)

Like making tea, there are a large number of ways in which we can write the code for our program, save it to a file, compile the file and then run it. The code can be written in any text editor (such as notepad, vi, emacs) and saved to a file - Note that word-processing applications such as Microsoft Word are not ideal because they do not normally store files as simple text (ascii) format, and may insert special formatting characters which the compiler won’t like.

The compiler and runtime environment for Java is provided for free by Sun (http://java.sun.com) so we could down load this and, having written our program, run it through the compiler and execute the result. Again this doesn’t sound too bad but the actual practice is a bit trickier, especially if you are new to this.

Over the years (computer programming languages have been around for about 50 years) programmers have realised that they needed some power tools to make the job easier, rather than using a collection of hand tools. The main tool used for programming is given the rather grandiose name Integrated Development Environment or IDE for short. IDEs normally provide an editor for writing the code, a compiler for compiling the code (or in the case of Java, have the Sun Java compiler built in) and have a debugger – which allows us to see how the code actually executes. Fortunately for us, a number of very good Java IDEs are freely available. For this tutorial I am going to use the Eclipse IDE and as a way of getting started I suggest EasyEclipse (http://www.easyeclipse.org – confusingly there are a number of different "flavours" of Eclipse – they are basically the same but have different sets of features packaged with them). Other free IDEs are Sun NetBeans and Oracle JDeveloper (google for them if interested).

So download and install your IDE of choice. For the rest of this tutorial I am going to be using EasyEclipse desktop edition, but pretty much any Eclipse distribution will look similar (although some tools may be missing or different).

Once you have downloaded EasyEclipse, and run the installer for your operating system, start it up and you should be prompted for the location of your workspace -

You can choose any location that suits you, it is the place that your files will be stored, so remeber where it is.

You should then get to the main workspace

In the next section we look at creating the SayHello class.

 

Creative Commons License

This work is Copyright Chris Hunter 2007, you may use it for non-commercial purposes
under the Creative Commons license Creative Commons Attribution-Noncommercial-Share Alike.

Edit - History - Print - Recent Changes - Search
Page last modified on August 29, 2007, at 02:07 PM