Книга: Java For Kids: NetBeans 8 Programming Tutorial
Назад: A Brief Word on the Course:
Дальше: 2 Java Program Basics


 

G:\Kidware_Software_Woman_Teacher_Standing_Pointing_Right.png

Preview

You are about to start a new journey.  Writing programs that ask a computer to do certain tasks is fun and rewarding.  Like any journey, you need to prepare before starting. 

 

In this first class, we do that preparation.  You will learn what Java is and why you might want to learn Java.  You will download and install the Java development software and download and install the software that will help you create Java programs.  Once the preparation is done, you will run your first Java application to check that you have prepared properly.  Let’s get started.

 

What is Java?

 

Java is a computer programming language developed by Sun Microsystems.  A programming language is used to provide instructions to a computer to do specific tasks.  Java is a new language (being created in 1995) and has been very successful for many reasons.

 

The first reason for Java’s popularity is its cost – absolutely FREE!!  Many other programming languages sell for hundreds and thousands of dollars, which makes it difficult for many people to start learning programming.  A second reason for the popularity of Java is that a Java program can run on almost any computer.  I’m sure you’ve seen programs that only run on Linux computers or Windows-based computers.  With Java, there is no such thing as a Linux version or a Windows version of a program.  We say that Java programs are platform-independent

 

 

Java can be used to develop many types of applications.  There are simple text-based programs called console applications.  These programs just support text input and output to your computer screen.  You can also build graphical user interface (GUI, pronounced ‘gooey’) applications.  These are applications with menus, toolbars, buttons, scroll bars, and other controls which depend on the computer mouse for input.  Examples of GUI applications you may have used are word processors, spreadsheet programs and computer games.  A last application that can be built with Java are applets.  These are small GUI applications that can be run from within a web page.  Such applets make web pages dynamic, changing with time.  I think you can see the versatility of Java.  In this class, we work mainly with simple console applications.  This allows us to concentrate on learning the basics of Java without getting lost in the world of GUI’s. 

 

Another popular feature of Java is that it is object-oriented.  This is a fancy way of saying that Java programs are many basic pieces that can be used over and over again.  What this means to you, the Java programmer, is that you can build and change large programs without a lot of additional complication.  As you work through this course, you will hear the word object many, many times.

 

A last advantage of Java is that it is a simple language.  Compared to other languages, there is less to learn.  This simplicity is necessary to help insure the platform-independence (ability to run on any computer) of Java applications.  But, just because it is a simple language doesn’t mean it lacks capabilities.  You can do anything with Java that you can with any of the more complicated languages.

 

 

Why Learn Java?

We could very well just ask the question – Why Learn a Programming Language?  There are several reasons for doing this.  First, if you know how to program, you will have a better understanding of just how computers work.  Second, writing programs is good exercise for your thinking skills – you must be a very logical thinker to write computer programs.  You must also be something of a perfectionist – computers are not that smart and require exact, perfect instructions to do their jobs.  Third, computer programmers are in demand and make a lot of money.  And, last, writing computer programs is fun.  It’s rewarding to see your ideas for a certain computer program come to life on the computer screen.

 

So, why learn Java?  We’ve already seen some of the advantages of using and learning Java – it’s free, it’s platform-independent, it can be used to write a wide variety of applications and it is object-oriented.  And, another reason for learning Java is that it is one of the easiest languages to learn.  Recall Java is a simple language with not a lot of instructions to learn.  Because of its simplicity, you can learn to write Java programs very quickly.  But, just because you can write your first program quickly doesn’t mean you’ll learn everything there is to know about Java.  This course just introduces Java.  There’s still a lot to learn – there’s always a lot to learn.  So, consider this course as a first step in a journey to becoming a proficient Java programmer.

 

A Brief History of Programming Languages

 

We’re almost ready to get started.  But, first I thought it would be interesting for you to see just where the Java language fits in the history of some other computer languages.  You will see just how new Java is!

 

In the early 1950’s most computers were used for scientific and engineering calculations.  The programming language of choice in those days was called FORTRAN (FORmula TRANslator).  FORTRAN was the first modern language and is still in use to this day (after going through several updates).  In the late 1950’s, bankers and other business people got into the computer business using a language called COBOL (the letter B stands for business, I can’t remember what the other letters mean).  Within a few years after its development, COBOL became the most widely used data processing language.  And, like FORTRAN, it is still being used today.

 

In the 1960’s, two professors at Dartmouth College decided that “everyday” people needed to have a language they could use to learn programming.  They developed BASIC (Beginner’s All-Purpose Symbolic Instruction Code).  BASIC (and its successors, GW-BASIC, Visual Basic, Visual Basic .NET) is probably the most widely used programming language.  Many dismiss it as a “toy language,” but BASIC was the first product developed by a company you may have heard of – Microsoft!  And, BASIC has been used to develop thousands of commercial applications.

 

Java had its beginnings in 1972, when AT&T Bell Labs developed the C programming language.  It was the first, new scientific type language since FORTRAN.  If you’ve every seen a C program, you will notice many similarities between Java and C.  Then, with object-oriented capabilities added, came C++ in 1986 (also from Bell Labs).  This was a big step.

 

On May 23, 1995, Sun Microsystems released the first version of the Java programming language.  It represented a streamlined version of C and C++ with capabilities for web and desktop applications on any kind of computer.  No language before it had such capabilities.  Since this introduction, just a few years ago, millions of programmers have added Java capabilities to their programming skills.  Improvements are constantly being made to Java and there is a wealth of support to all programmers, even beginners like yourself, from the vast Java community.  Let’s start your journey to join this young, vital community.

 

 

Let’s Get Started

 

Learning how to use Java to write a computer program (like learning anything new) involves many steps, many new terms, and many new skills.  We will take it slow, describing each step, term, and skill in detail.  Before starting, we assume you know how to do a few things:

 

 

 

You have probably used all of these skills if you’ve ever used a word processor, spreadsheet, or any other software on your computer.  If you think you lack any of these skills, ask someone for help.  They should be able to show you how to do them in just a few minutes.  Actually, any time you feel stuck while trying to learn this material, never be afraid to ask someone for help.  We were all beginners at one time and people really like helping you learn. 

 

 

Let’s get going.  And, as we said, we’re going to take it slow.  In this first class, we will learn how to install Java on your computer, how to load a Java program (or project), how to run the program, and how to stop the program.  It will be a good introduction to the many new things we will learn in the classes to come.

 

 

Downloading and Installing Java

 

To write and run programs using Java, you need the Java Development Kit (JDK) and the NetBeans Integrated Development Environment (IDE).  These are free products that you can download from the Internet.  Complete download and installation instructions are provided in the Appendix (Installing Java and NetBeans) included with these notes.

 

NetBeans – A Java Development Environment

 

The process of creating and running a Java program has three distinct steps:

 

 

Don’t worry too much about what goes on in each of these steps right now.  One way to complete these three steps is to first type the program using a basic editor and save the resulting file.  Next, the compile and run steps can be completed by typing separate commands to your computer. 

 

Very few Java programmers write programs in this manner.  Nearly all programmers develop and run their programs using something called an Integrated Development Environment (IDE).  There are many IDE’s available for Java development purposes, some very elaborate, some very simple.  In these notes, we will use an IDE called NetBeans.  It was installed when you installed Java from the Internet.

 

 

 

Starting NetBeans

 

We’re ready to try out all the new files we’ve installed on our computer.  We’ll learn how to start NetBeans, how to load a Java project, and how to run a project.  This will give us some assurance we have everything installed correctly.  This will let us begin our study of the Java programming language.

 

Once installed, to start NetBeans:

 

 

(Some of the headings given here may differ slightly on your computer, but you should have no trouble finding the correct ones.)  If you put a shortcut on your desktop in the installation, you can also start NetBeans by double-clicking the correct icon.  The NetBeans program should start.  Several windows will appear on the screen.

 

Upon starting, my screen shows a Start Page with lots of helpful information.  You can spend some time looking through these if you wish.  Close the Start Page by clicking the X.

 

 

Next, choose the Window menu option and select Projects.

The window should now look like this (this is where we will always start to build and run Java programs):

 

 

This screen displays the NetBeans Integrated Development Environment (IDE).  We will learn a lot more about this IDE in Class 2.  Right now, we’re just going to use it to test our Java installation and see if we can get a program up and running.  Note the location of the file view area, editor view area and the main menu.  The file view tells you what Java programs are available, the editor view area is used to view the actual code and the main menu is used to control file access and file editing functions.  It is also used to compile and run the program.

Назад: A Brief Word on the Course:
Дальше: 2 Java Program Basics

Ddd
ddd
Fgg
Ghhg
Zeljko Savic
daj
Zeljko Savic
daj