How Java Works
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have you ever pondered the workings of computer programs? Have you ever wanted to learn how to write your own computer programs? This article is for you, whether you are 70 years old and have been curious about computer programming for 20 years or you are 14 years old and want to learn how to write your first game. In this edition of HowStuffWorks, I’ll show you how to program in the Java programming language to learn how computer programs work.
Java course in Aurangabad
In order to teach you about computer programming, I am going to make several assumptions from the start:
I am going to assume that you know nothing about computer programming now. If you already know something then the first part of this article will seem elementary to you. Please feel free to skip forward until you get to something you don’t know.
I’m going to assume that you have some knowledge of the computer you’re using. That is, I am going to assume that you already know how to edit files, copy and delete files, rename files, search your system, and so on. For simplicity, I am going to assume that you are using a machine running Windows 95, 98, 2000, NT or XP. It should be relatively straightforward for people running other operating systems to map the concepts over to those.
I am going to assume that you have a desire to learn.
All of the tools you need to start programming in Java are widely available on the Web for free. There is also a huge amount of educational material for Java available on the Web, so once you finish this article you can easily go learn more to advance your skills. You won’t need to buy any compilers, development environments, books, or other materials to learn Java programming here. Once you learn Java it is easy to learn other languages, so this is a good place to start.
Having said these things, we are ready to go. Let’s get started!
Contents
A Little Terminology
Downloading the Java Compiler
Your First Program
Understanding What Just Happened
Bugs and Debugging
Variables
Looping
A Little Terminology
Java classes in Aurangabad
Keep in mind that I am assuming that you know nothing about programming. A few terms from the English language that will help you understand: A computer program is a set of instructions that direct a computer precisely how to operate. The instructions might tell the computer to add up a set of numbers, or compare two numbers and make a decision based on the result, or whatever. However, just like a recipe is a set of instructions for a cook or musical notes are a set of instructions for a musician, a computer program is nothing more than a set of instructions for the computer. The computer does what you tell it to do and does something useful in the process, like balancing your checkbook, playing a game on the screen, or using a word processor. Programming language – In order for a computer to recognize the instructions you give it, those instructions need to be written in a language the computer understands — a programming language. There are many computer programming languages — Fortran, Cobol, Basic, Pascal, C, C++, Java, Perl — just like there are many spoken languages. They all express approximately the same concepts in different ways.
Compiler – A compiler translates a computer program written in a human-readable computer language (like Java) into a form that a computer can execute. You have probably seen EXE files on your computer. These EXE files are the output of compilers. They contain executables — machine-readable programs translated from human-readable programs.
Java Training in Aurangabad
A compiler for the Java language is required in order to begin writing computer programs in the programming language known as Java. The next section guides you through the process of downloading and installing a compiler. Once you have a compiler, we can get started. This process is going to take several hours, much of that time being download time for several large files. In addition, you’ll need about 40 megabytes of free disk space (check to see if you have enough before you start). Getting the Java Compiler Downloaded In order to get a Java development environment set up on your machine — you “develop” (write) computer programs using a “development environment” — you will have to complete the following steps:
The Java development environment, including the compiler and other tools, can be downloaded in a large file. Download a large file containing the Java documentation.
If you do not already have WinZip (or an equivalent) on your machine, you will need to download a large file containing WinZip and install it.
Install the Java development environment.
Install the documentation.
Adjust several environment variables.
Give everything a shot. Before getting started, it would make things easier if you create a new directory in your temp directory to hold the files we are about to download. We will call this the download directory.
Step 1 – Download the Java development environment
Go to the page http://java.sun.com/j2se/1.4.2/download.html. Download the SDK software by clicking on the “Download J2SE SDK” link. You will be shown a licensing agreement. Click Accept. Select your operating system and download the file to your download directory. This is a huge file, and it will take several hours to download over a normal phone-line modem. The next two files are also large.
Step 2 – Download the Java documentation
Download the documentation by selecting your operating system and clicking the SDK 1.4.1 documentation link.
Step 3 – Download and install WinZip
Visit the website http://www.winzip.com/ to download a trial version of WinZip if you do not already have one installed on your computer. Run the EXE you get to install it. It will be used to install the documentation shortly. Step 4 – Install the development kit
Execute the j2sdk-1_4_1-*.exe file you downloaded in the first step. It will unpack and install the development kit automatically.
Step 5 – Install the documentation
Read the installation instructions for the documentation. They’ll tell you to move the documentation file into the same directory as the development kit you just installed. Unzip the documentation and it will drop into the proper place.
Step 6 – Adjust your environment
You must alter your path variable in accordance with the instructions on this page. This is most easily done by opening an MS-DOS prompt and typing PATH to see what the path is set to currently. Then open autoexec.bat in Notepad and make the changes to PATH specified in the instructions.
Step 7 – Test
Now you should be able to open another MS-DOS window and type javac. If everything is set up correctly, you should be able to read a two-line text that explains how to use javac. That means you are ready to go. If you see the message “Bad Command or File Name” it means you are not ready to go. Figure out what you did wrong by rereading the installation instructions. Make sure the PATH is set properly and working. Go back and reread the Programmer’s Creed above and be persistent until the problem is resolved.
You are now the proud owner of a machine that can compile Java programs. You are ready to start writing software!
Moreover, you just unpacked a demo directory full of interesting examples. All of the examples are ready to run, so you might want to find the directory and play with some of the samples. Many of them make sounds, so be sure to turn on your speakers. To run the examples, find pages with names like example1.html and load them into your usual Web browser.