Chapter 0: Introduction.
What Java is and what it is not
Java is an object oriented programming language that has evolved from and to substitute the C and C++ programming languages.
But why?
The main reason for Java to have evolved is "platform independence" we shall come to this part later.
When a programming language is designed, certain trade offs have to be made.
1) Ease of use versus Power
2) Efficiency versus Safety
3) Rigidity versus Extensibility
This also gives a more or less accurate comparison of C++ versus Java
Java has chosen all the latter parts of the trade offs- in other words, it is Powerful, Safe and highly Extensible.
Does it mean that Java is difficult?
Hardly. Once you get the hang of it, no programming language is more difficult than the other.
Is Java Inefficient.
This is difficult to answer. Immediately it might seem that java is slightly inefficient, especially in the smaller applications. Where C and C++ take seconds to get results, Java seems to be taking ages. But then, to gain something, something else has to be lost. However for scalable applications especially those designed for the web, with good performance tuning, Java can easily displace C++ as an alternative.
What is all this commotion about safety?
Well how would it be if anybody would be able to enter your house and get away with whatever you liked? Eat your favorite apple pie and leave the remains for you to weep about? Thats just the way it is here.
Java is very particular about what belongs to whom and how much permission anybody else has to your property. You, the programmer get to decide and restrict the access of every object.
Why not C++?
Well, C++ is notorious for two of its virally pervasive programming problems.
1) Memory Leak: This occurs when an application dynamically allocates storage and does not bother to free it. This thing is very easily overlooked by programmers and they end up clogging the memory and getting the system to a hangover.
2)Deadly Diamond Deadlock: This is another trauma of object oriented programming. We shall explain this after we have discussed the concepts of object oriented programming.
So what does Java do about these?
Not so fast. Let us just know that java overcomes these, and don't tempt yourself into finding out the answers immediately, allow me to preserve the suspense so that at the time of revelation, it will come as a beautiful surprise.
When the time is ripe, everything will be answered.
Whats so great about Java?
If its edge over C++ hasn't sufficiently impressed you, java has become synonymous with the world wide web. Why? Everybody seems to have a computer but does everyone have the same operating system? of course not, and that is where java comes in with its revolutionary "WRITE ONCE, RUN ANYWHERE" technology, so anyone with a java virtual machine (which is available free of cost from http://java.sun.com and is very small size-wise) can run your module and see it more or less just as you did (didn't we talk about platform independence?)
Anyway, here are a few Buzzwords that java attracts
Simple
Secure
Portable
Object-oriented
Robust
Multithreaded
High-performance
Distributed
Dynamic
(you can see what the creators had in mind here http://java.sun.com/docs/overviews/java/java-overview-1.html )
None of these would make much sense without a context and without a problem, so tell you what, let us get on with the language, and as and when the context arises, I shall pose the problem and give you insights on each of these.
And Please, Java is not enhanced html. Html is a markup language- meaning it is just a way of presentation, java on the other hand is a full fledged programming language, with extremely powereful features especially networking capabilities.
In the process of learning you shall really appreciate the power of java.
I have tried to make further reading a fun and enjoyable experience without trading off on the serious side of programming.
This manual is intended as a step by step guide for the basic and advanced users and will build and strengthen the fundamentals of the languae and go one step ahead to unleash the power of the language.
Suggested Books
Java complete reference- Herb Shuldt
Head first java- Sierra & Bates
Java, how to program- Deitel & Deitel
Core Java- sun microsystems press.
Thinking in java- Bruce Eckel
The next tutorial will teach you how to setup the java software development kit and other related topics so that you can be ready to start programming
OpaQue : CHANGED THE FONT : It was hurting..
Chapter 1
Setting up your system for java software development.
Step 1: Get the Java software development kit
Download the latest version of J2SDK (Java 2 Software Development Kit) Version 1.5.0 update 4 (suitable for your operating system) from the website http://java.sun.com or get it from a CD especially those that come free with your computer magazine or with a Java text.
Note: You need to get the Java SDK and not the Java Runtime Environment (JRE). The JRE is bundled within the SDK so don't worry about that.
And another thing. Download the corresponding API specification docs ( in zip format) from the same site. This is an indispensible reference guide to your whole software development. This is avaible only on the sun site and will most probably not be packaged with the J2SDK on any free distribution CD.
Step 2: Installing the SDK and Configuring your PC for the development.
In this course I shall be using the SDK on a windows machine and therefore all the configuring is described for a windows machine only. A linux/mac os user should have enough information to do it himself. In any case, the whole produre is properly described in the Installation notes section of the Readme when you install the SDK.
Firstly run the sdk installation file and ask the program to install the into the folder c:\j2sdk5.0 or d:\j2sdk5.0 or whichever drive you wish to install it. It is better if you install it in the first level itself. For example installing it in c:\xyz\j2sdk5.0 etc will cause certain inconveniences at a later point of time.
Let us assume we have installed it into the c:\j2sdk5.0 directory.
Now look into the directory and you'll see folders like
bin <- this is where the compiler, and other utilities are stored
demo <- you will find some demo goodies here
include <- the native library files
jre <- the runtime environment is here
lib <- the java library files
and files like
readme.htm <- read this for everything you need to know about using the sdk
readme.txt <- a text version of the same
src.zip <- this is where all the source files are kept, or "classes" as they are called in java ( The bricks of a java program.) Unzip the contents to a folder called src in your j2sdk5.0 folder. We will need to take a peek into this sometime later.
and other files.
Another thing you must do is unzip the API specification document's zip file into a folder docs in the j2sdk5.0 folder.
Now that we are done with the installation, we shall configure the pc.
Open the command prompt and type the following EXACTLY
we shall denote the command prompt as $ (omit typing this at the prompt)
$SET PATH=%PATH%;C:\j2sdk5.0\bin;
This tells the OS to look for executables in the directory c:\j2sdk\bin
and now
$SET CLASSPATH=%CLASSPATH%;c:\j2sdk5.0\lib;.;
And this tells the OS to look for classfiles in the lib directory and also the current directory which is "." . This step is called Setting the Classpath and the above, as is obvious is called Setting the path.
Restart the computer or atleast the DOS for these changes to take effect.
Getting yourself some text editors.
During the stage of development I suggest the we use the "EditPlus" text editor which is a good environment to write code, not fanciful, fast and free to use. You can download it from the editplus site. It is suggested not to use Integrated Development Environments (IDEs) like NetBeans or SunOne Studio, they make complex things easy and easy things complex and guzzle on your system resources.
Another text editor is the textpad available at textpad.com
You can if you feel comfortable use the edit utility of DOS, but its a bit too stark with no mouse navigation or GUI.
I shall use the editplus text editor in all the further coding we are going to do.
So now we're done, ready to start coding, but before that we shall get acquainted with concepts of object oriented programming for we will be referring to most of the OOP jargon in the rest of the tutorials.
So tomorrow, an introduction to OOP.
Have a nice day!

