Monday, 14 December 2009

Java programs without BlueJ

It is quite simple to make Java program without BlueJ

Download Java


Install the package

Set up the environment first

Go to Control Panel and open System then choose the Advanced System Settings

It is quite simple to make Java program without BlueJ but you must set up the environment firstGo to Control Panel and open System then choose the Advanced System Settings In the new window choose Environment Variable



Check if CLASSPATH has been set and the path variable has the path to your JDK folder. You must remember if you set it up yourself then put a dot as the first item in the CLASSPATH and then the path where your jar files are stored(search for them)

Make sure you put the path where your javac.exe file is stored most probably it will be inside on this path C:\Sun\SDK\jdk\bin

Once this is done you are ready to go

Fire up NotePad and type the following snippet

[caption id="attachment_28" align="aligncenter" width="512" caption="First Java program"]

Now you must remember 3 things

1) Where you are saving this code

2) Name of the file should be entered in the file save box as "ABC.java" Nothe double quotes, it is important you do this or else in most systems notepad will save it as ABC.java.txt.

3) The name of the file must be same as the class name.

[caption id="attachment_29" align="aligncenter" width="650" caption="Mind the doule quotes and name of the file"]

Compile and Run

Open the DOS prompt, if you cannot find it on vista just type cmd on the start menu and the icon shown will be DOS Prompt.

I hope you know where you have stored your file ABC.java, navigate to that place. I will not cover DOS commands, if you need help leave a comment

When you have reached the place where you have stored the file just type the following command

javac ABC.java

if there is any error it will show up other wise it will show nothing just the prompt will come back

then type java ABC

and you should get a message Hello World just below the prompt, congratulation you have your first Java program

If you have any queries please feel free to leave comments for me

Friday, 10 April 2009

Learn Programming Easily Step 4

In the last post I had discussed the String or Alpha-Numeric Constant. In this post I shall endeavor to discuss Numeric Constants. They are the most important constants in programming. And you must learn to use them properly if you have to learn programming easily. We must be able to differentiate between alpha-numeric and numeric constant. If a student is unable to this basic task then the whole point of learning programming is defeated.


First question might be what are numeric constants? To put it simply any number without an enclosing quotation mark is a numeric constant. For example

1

23.45

45678

326478


These are all valid numeric constants. Now if we have to see the difference between valid and invalid numeric constants.


Constant
Valid/Invalid
5.345
Valid
"5.345"
Invalid
Sudeep45
Invalid
245
Valid

I hope by now you understand the difference between a valid and invalid constant. A numeric constant may be preceded by a sign +.-. For Example

-34
+678
In the previous examples these signs were missing. When it is a valid numeric constant and there is no sign then please assume them to be positive because the computer does the same thing. These are some small things you must remember if you want to learn programming easily.Let us go back to the core concept of constant and see if the following instructions are correct.

34.56=67
"Sudeep"=45
34="Sandeep"
47=67=32

Let us analyze these examples and see if they are valid. First line essentially says 34.56 equals to 67 and please note it is not a question but an assertion. Thus computer is trying to put the value of 67 in 34.56. Now that is quite stupid. Both the numbers are different with different values we cannot replace one value with another that is not possible is it?. Second example shows a Alpha-Numeric Constant being given a value of 45. So what it is trying to do is say the word or the name Sudeep means 45. Again it is not question but an assertion. Lets say your name is John and I say John means 23. Does it make any sense. No, it has no logic and as I had mentioned programming is all to do with logic. One more important point to note is that the name Sudeep is enclosed in double quotes thus making it is an alpha-numeric constant. Therefore by definition a constants value cannot be changed. 5litre does not mean 3 tommorow why because 5 has a fixed value or a constant value which cannot be changed. Same way anything inside a double quote has a fixed value and its value cannot be changed.

I hope by now you can differentiate between Numeric and Alpha-Numeric constants. In all programming languages there are few more types of constants which sometime are essential for a particular case. If we have learn programming properly we must know each of them correctly and understand where we must use them. Because these post endevour to teach you programming easily therefore I have left those constants for later discussion.

Just as an exercise try to find out which of these constants are valid and what is their type.

"34.56/12"
12.56"wer"
67
"Sudeep + 56"

Thursday, 9 April 2009

Learn Programming Easily Step 3

I must apologize to the people following my site for not publishing an update for the past 2-3 days. I was a bit busy messing about with RSS and was sucked into the use of this format. Any way lets move on with what we were doing and that is learning the basics of programming.
As I showed you in my earlier post let me give you another example of a language neutral pseudocode

START
DISPLAY "2 + 2"
STOP

As you may have guessed this program will display 4 on the computer screen. WELL DONE..!

You are absolutely and utterly wrong. Why 2+2 is 4...? Yes you are correct in most circumstances yet this is the world of programming.
In this case I have used double quotes " this directs the computer to print whatever written inside the quotes as it is without using any intelligence or any logic. You get what you see no computation no meaning no logic nothing. Therefore the computer forgets about mathematics and prints whatever written inside the double quotes as it is. Again to re-emphasize my point. Let me ask you another question if I write

DISPLAY "Sandeep+4" what should it print. Forget about the meaning, don't think anything about the meaning(I accept the phrase is quite nonsensical) So if you were a ROBOT and just printing it as it is then it will print Sandeep+4 on the screen. For now please remember this do not forget it

DOUBLE QUOTE MEANS AS IT IS. IT DOES NOT HAVE ANY MEANING,NO MATHS,NO LOGIC,NO ANSWER, NOTHING. SHOWS ON THE SCREEN AS IT IS

With this wonderful weapon lets boldly go where no man has ever gone.... oops the Star Trek fan is getting a bit excited.
So what is this thing called. Is there a name for such things which are printed as it is and are written in double quotes?. There are plenty of names different people use to denote this kind of data. My favourite is 'Alpha-Numeric' constant. Again it is very important to understand the name. Lets take the word 'Constant' what does it mean? Again it means exactly what it sounds like.
A Constant is something which does not change irrespective of what you do with it. Best example in this category is your name. Lets say my name is Bruce does the meaning of Bruce changes every day or can you change the meaning of Bruce anytime you want. Can I say Bruce means Eddie or Bruce means 5. That is jibberish. You can noot change the value of a constant irrespective of what you do.

Now lets take the first part 'AlphaNumeric' it means the constant may have alphabets as well as numerics. Because we are not concerned with the value of a constant or what it means. To write your name on the screen you shall write DISPLAY "". To write your address DISPLAY "12 chester road london N2 3P". DISPLAY "MY SKYPE ID IS DER£$". This is sometimes also called String but lets keep thing simple for now. Anything enclosed in a double quote is a String/Alpha Numeric Constant

"23+43" prints------------------------->23+43
"Sudeep"prints----------------------->Sudeep
"*3+(78/34)+3" prints--------------->3+(78/34)+3
Until my next post keep repeating anything inside a double quote has no meaning for the computer. It will print it as it is. In my next post I will handle other data types or other constants.

Monday, 6 April 2009

Learn Programming Easily Step 2

If you have understood what I have tried to convey in my previous post then it is time to move forward. As I mentioned that programming is
A set of logical instructions written to perform a specific task or tasks.
In my previous example I took a mundane task of clearing the bins now lets assume these tasks are to be performed by a computer therefore I shall again over simplify the situation and take a simple task of printing some message on the screen or the output device. Lets say the message is "Happy New Year". If you believe the sci-fi movies and think just saying "Computer show me Happy New Year on my screen" and your computer will do so... then all I can say dream on. Most computers cannot do so and even the ones which may be able to understand speech are very limited in their ability. Have you ever tried to dictate on your computer using the popular speech programs?. Then there is a small problem...computer as a machine does not understand English for that matter any human language. It can understand the language of 0's and 1's called binary thus making it understand your language is a bit of a problem. So how do we go about


My wonderful diagram shows you the task which has to be performed. 'INPUT' means the command or the instructions that you gave to the computer.As I said computer cannot understand the language you speak. So how do we convert it into something which it can understand. There in lies the magic of compilers or interpreters.




I Shall not go into the gory details of compilers just as a simple explanation compilers are a piece of code or programs which take instructions in human readable format and convert them in a format which computer can understand. There are lot of steps involved but that is for some other time. As you know English or any language has a grammar or a way of witting and reading in the same way programs are written following a specific grammar which is quite rigid compared to normal human languages. This grammar is called syntax in technical terms. Therefore if you want to become a crack programmer you must learn the language first. There are many languages each with its own strong points and weaknesses. Some of the well known ones are C++/C, Visual Basic, JAVA, C# etc. But take my word for it the number of languages are innumerable.

Getting back to our discussion as how to print "Happy New Year" on the screen. Now I can say

START
DISPLAY "Happy New Year".
STOP

There we have it our own program to print a message on the screen.(May be I can sell it for a few thousand pounds to IBM).

Your next question might be which language have I used? The answer is none this a style of writing program which are very close to the real thing yet they are not bound by any language. This style sometimes is called 'pseudocode'. For most part of the introduction I shall follow this pattern. Once the basics are out of the way I will take up some language to further illustrate my points.



Friday, 3 April 2009

Baby Steps 1

Okay guys here goes step one.
Lets first understand what is a software or a programme I don't know what books say or the proper definition but I shall give you my understanding of this art.
A program is a set of logical instructions written to perform a specific task or tasks
Lets break it up in different part.
To begin with what do I mean by tasks ?.............Does it mean buying groceries or taking the rubbish out or cleaning your room ? Yes and No. Yes because they are example of tasks which you may perform in your daily life but these are not the tasks I am aiming for in the above mentioned definition. These tasks one day may be done by by robots or computers but for now lets keep it simple shall we. A task for your program may be adding two numbers and printing the answer on the screen. Or it may be adding all the marks obtained by every student in your class and find the average marks. Or it may be finding the shortest route between to cities. the list is endless and it becomes more and more complicated as we go on.
The first part of definition was set of instructions. This we all are familiar with. Do you remember when your mother gives you a list of do's and dont's when you leave for school or when she instructs you to perform your daily chores around the house. Lets us see a simple instruction dealing with garbage.

Step 1 Empty The Bins Inside the House
Step 2 Put New Bin Bags Inside The House
Step 3 Carry The Old Used Rubbish Bags Outside
Step 4 Bin The Bags In The Rubbish Bin

So we see a simple chore is actually a set of instructions.
I shall rewrite these steps in a different order.

Step 1 Bin The Bags In The Rubbish Bin
Step 2 Put New Bin Bags Inside The House
Step 3 Carry The Old Used Rubbish Bags Outside
Step 4 Empty The Bins Inside The House

Do you see the difference? Lets imagine you are a robot who has no brains but understands english. Please switch off your brain for a instance and read the first step. 'BIN THE BAGS IN THE RUBBISH BIN' ..what bin bags......where do i get them....?????
'PUT NEW BIN BAGS INSIDE THE HOUSE' .....Where do I put them no space on the already full bins.....?????
'CARRY THE OLD USED RUBBISH BAGS OUTSIDE'....what old bags there are none......????
If you were a computer who only understands the instruction without any power of thinking the above mentioned steps would be impossible. What is the difference between the two sets. As you can clearly see the instructions are the same then why...because we have changed the order and the order has no meaning or logic behind it for the computer to understand.
If you are confused I shall advise you to read the text again and wait till you understand to go any further because I am going to develop the idea further in my next post.

Learn Programming The Easy Way

Hi guys this is my first blog about programming.
Here I intend to teach you how to write programmes on your own without having to read from the book after each line.
I have extensive teaching experience with students of all ages. I have been teaching for the past ten years. I have taught many programming languages and tools with ever changing versions and syntaxes etc. I started long time back in the early 90's with my favourite GW-Basic and fell in love with the concept of creating things from the scratch or watching somebody else use the utility you have created. Then I progressed to COBOL and FORTRAN in between all this I learnt dBase,Lotus etc. COBOL was a language I never could appreciate because I never got a chance to work on a big data intensive project.A shame really would have loved to harness the power of COBOL and see it in action.Then I moved on to something which would truly open my eyes to the power of computer programmes and that was C. Yes you must have read it 100 times in various places and whatever you read about the power of C most probably is absolutely true. I learnt how the system works specifically the internal workings and the ROM-BIOS routines
or the DOS routines, Graphics at its lowest level, device drivers etc etc etc. As you can see I am a bit of a fan. Through C I learn assemble language and its amazing power.From then on I have learnt many languages but my favourite is still C. On pure windows platform nothing beats my good old friend Visual Basic. During my masters I went on to become a MCSD in VB.NET.
As for the students I have taught none of them ever failed in Computer Science nor they have ever got less than first class. I decided it was a time to share my style and experience with a wider audience and see if my technique can benefit people from all region. Thus I have kept it free and non-commercial.
The first thing you must understand that there is no shortcuts to learning programming. I have no magic wand which will make you an expert coder by just wafting the wand thrice.
What I intend is to make you learn programming by following simple examples which are described in a non-technical language with proper illustrations to match.
I shall give you simple exercises to make you understand as well as revise what you have learnt