Printer Friendly
The Free Library
14,694,704 articles and books
Member login
User name  
Password 
 
Join us Forgot password?

Getting started with JAVA.


Why Java?

You might ask, "Why Java?' That's a good question, especially if you are new to the language and have not heard all the buzz about it yet. How does a programming language that has only been around since 1995 and is quite similar in syntax and design to C++ become so widely adopted? Why not just stick to languages that have been used for decades: C, C++, COBOL COBOL: see programming language.
COBOL
 in full Common Business-Oriented Language.

High-level computer programming language, one of the first widely used languages and for many years the most popular language in the business community.
, Fortran, and so on?

Relative to the other programming languages used today, Java is in its infancy. (Sun Microsystems released the first version or" Java in 1995.) Yet Java has become one of the most popular languages used in programming today. Java is an object-oriented programming language object-oriented programming language - object-oriented programming  with syntax and keywords almost identical to C++, another object-oriented language that has been used extensively for over 20 years. So why learn a new programming language that is similar to an established programming language? First of all, Java is easier to learn than other object--oriented languages. When developing Java, its creators took all of the good features of the existing object-oriented programming languages such as C++, Ada, and Smalltalk, and removed most of their flaws and peculiarities. There are a lot of aspects of the Java language that are consistent and make sense, thereby making it easier to learn.

When I first learned C++ in college, we spent weeks learning just to manipulate and display strings. It was hard to remember which function to use when, and none of it ever made any sense to me. When 1 first started to learn Java, I was immediately impressed with the case with which strings are handled. It was one of the first simplicities of Java that got me excited about the language. I want to emphasize that I did not say Java is easy to learn. I said Java is easier to learn than other object-oriented programming languages, specifically C++ but I think you will find that Java is straightforward, powerful, well designed, and an enjoyable language with which to program.

The Java Virtual Machine A Java interpreter. The Java Virtual Machine (JVM) is software that converts the Java intermediate language (bytecode) into machine language and executes it. The original JVM came from the JavaSoft division of Sun.  

The elegance and power of how Java is designed is only part of the reason why Java has become so prevalent in today's software development. Platform independence is what Sun boasts the loudest about regarding Java-and with good reason!

A Java program can be written once and then run on many different devices. Sun uses the slogan "write once, run anywhere.' I used the term boast because the validity of the claim to true platform independence has been argued by some; however, in an ideal situation, most Java programs can be moved from one device to another without any modifications to the code.

For example, suppose that you want to develop a program that is to run on a PC with Microsoft Windows and a hand-held PC running the Palm OS. These two platforms have little in common. If you were to write this program using a language other than Java, you would likely write the program twice- once for Windows, and again for the Palm version. The programs would probably look quite different, and possibly would be written in different languages. With Java, you are not concerned with the target platform. The exact same program can run on Windows and the Palm OS, without changing the code at ai1. This "write once, run anywhere' capability is an exciting feature of Java that makes it appealing for anyone developing software.

Q & A

Q: So, how is platform independence possible?

A: Well, I have been leading you up to that question. How do you think it is possible?

Q: I am assuming you recompile To compile a program again. A program is recompiled after a change has been made to it in order to test and run the revised version. Programs are recompiled many times during the course of development and maintenance. See compile.  the program, using a compiler designed for the specific platform you are targeting

A: Yes and no. You do use a compiler for a specific platform, but there is no recompiling. In fact, compiled Java code, which is referred to as bytecode, is well defined and looks the same no matter what type of device you are targeting. This is because in Java, the platform you target is a Java Virtual Machine, or JVM See Java Virtual Machine.

JVM - Java Virtual Machine
 for short. You do not write Java programs for Windows, Unix, a Palm PC, or any other device. You write Java programs to run on a JVM.

Q: So if I want my Java program to run on Windows, I need a JVM for Windows?

A: Exactly. And if you want your Java program to run on your watch, you need a JVM for your watch. If you want a Java program to run on your cell phone, you need a JVM for your cell phone, and so on.

Q: And the JVMs are written in Java?

A: No. Interestingly enough, most JVMs are written in C or C++. When you run a Java program, you are really running a JVM, and the JVM is interpreting your Java code.

Q: This must make Java programs considerably slower.

A: That is a definite concern. Five years ago, I would have had to concede that a Java program was noticeably slower than a C or C++ program But modem JVMs are much more efficient and include a feature known as a Just-in-Time (JIT) compiler. A J1T compiler actually takes your Java bytecode and translates it into native code. This translated code will run just as fast as any C++ program There is more overhead at the beginning of the Java program when the code is being translated, but the end result of a JIT compiler is well worth it.

Q: Can you look at this translated Java code and just use It directly?

A: No. Most J1T compilers do all of their work In RAM, so this translation takes place each rime you run the Java program. The point of Java is not to focus on trying to create native code, since native code is inherently non-platform-independent. The point of Java is to write code that will run on a JVM. That way, your Java program tan run on any device that has a JVM, Think about this: You can write a Java program, and three years from now that program can run on an electronic device that doesn't even exist today, as long as the device has a JVM for it.

The Editions of Java

When Java was introduced, it primarily consisted of two components: the programming language specification A programming language specification is an artifact that defines a programming language so that users and implementors can agree on what programs in that language mean.

A programming language specification can take several forms, including the following:
, and the Java runtime environment The combination of the Java Virtual Machine, the core class library and supporting files, all of which are required to run a Java program. See Java and Java Virtual Machine.  specification that described the features of a JVM. As the Java language evolved over the years, Sun Microsystems gradually added new specifications and technologies that made Java more than just a programming language.

For example, servlets and JavaServer Pages were introduced to provide a mechanism for using Java to create dynamic Web pages. Javabeans provide a Java software component architecture. Enterprise JavaBeans provide a mechanism for developing distributed applications. Each of these technologies has its own specification.

Soon after the release of Java 2, however, (which coincided with the release &version 1.2 of the Java Development Kit (language, compiler) Java Development Kit - (JDK) A free Sun Microsystems product which provides the environment required for programming in Java. The JDK is available for a variety of platforms, but most notably Sun Solaris and Microsoft Windows.

http://java.sun.
), to create common runtime environments for Java developers to target, Sun grouped their major Java programming technologies into three editions:

* J2ME (Java 2 Platform, Micro Edition) A version of Java 2 for cellphones, PDAs and consumer appliances. J2ME uses the K Virtual Machine (KVM), a specialized Java interpreter for devices with limited memory. : Java 2 Platform, Micro Edition (language, programming) Java 2 Platform, Micro Edition - (J2ME) Sun's Java platform for consumer devices.

J2ME defines Configurations and Profiles for different classes of small memory device, from smart cards to pagers to set-top boxes.
 

* J2SE (Java 2 platform, Standard Edition) See Java 2.

J2SE - Java 2 Platform, Standard Edition
: Java 2 Platform, Standard Edition (language, programming) Java 2 Platform, Standard Edition - (J2SE) Sun's Java programming platform aimed at network-oriented enterprise applications. J2SE comprises the Java 2 Software Development Kit (SDK) and the Java 2 Run-Time Environment.  

* J2EE (Java 2 Platform, Enterprise Edition) A platform from Sun for building distributed enterprise applications. J2EE services are performed in the middle tier between the user's machine and the enterprise's databases and legacy information systems. : Java 2 Platform, Enterprise Edition (language, programming) Java 2 Platform, Enterprise Edition - (J2EE) Sun's Java platform for multi-tier server-oriented enterprise applications.

The basis of J2EE is Enterprise JavaBeans (EJB).

See also the Standard edition J2SE and the Micro edition J2ME.
 

J2SE

J2SE is what I like to call the core Java language. This book focuses on the key elements of this Standard Edition. J2SE provides an environment for developing many different types of Java applications and includes support for GUI (Graphical User Interface) A graphics-based user interface that incorporates movable windows, icons and a mouse. The ability to resize application windows and change style and size of fonts are the significant advantages of a GUI vs. a character-based interface.  programming, threads, input/output, networking, XML XML
 in full Extensible Markup Language.

Markup language developed to be a simplified and more structural version of SGML. It incorporates features of HTML (e.g., hypertext linking), but is designed to overcome some of HTML's limitations.
, CORBA (Common Object Request Broker Architecture) A software-based interface from the Object Management Group (OMG) that allows software modules (objects) to communicate with each other no matter where they are located on a private network or the global , applets, javabeans, remote method invocation (programming) Remote Method Invocation - (RMI) Part of the Java programming language library which enables a Java program running on one computer to access the objects and methods of another Java program running on a different computer.

http://java.sun.com/products/jdk/1.
, security, and database access.

If you are interested in eventually taking the exam to become a Sun Certified Java Programmer, you need to become familiar with the J2SE.

J2ME

J2ME is not a slimmed-down version of J2SE. Instead, it establishes a procedure for defining what a particular JVM designed for an electronic device will provide. The J2ME technology has two components:

Configurations. Define the type of JVM that is being targeted.

Profiles. Describe specification details about the device that is being targeted. Each device has a profile listing the standard Java APIs available for that device. Configurations are composed of Java APIs and virtual machines designed to run on two different types of devices. The first type of device is those with 128-512K of memory. This configuration is called the Connected Limited Device Configuration The Connected Limited Device Configuration (CLDC) is a specification of a framework for Java ME applications targeted at devices with very limited resources such as pagers and mobile phones. The CLDC was developed under the Java Community Process as JSR 30 (CLDC 1.  (CLDC See J2ME. ), and the corresponding JVM is referred to as the K Virtual Machine, or KVM. The second configuration is for devices with more than 512K of memory. This configuration is called the Connected Device Configuration The Connected Device Configuration (CDC) is a framework for building Java ME applications on embedded devices ranging from pagers up to set-top boxes. However, there is also CLDC and MIDP to allow a more fine-grained distinction.  and uses the standard JVM, with all the same capabilities of a regular desktop computer. Profiles are defined by the Java Community Process Sun's system for allowing third parties to submit requests for new features to Java. JCP is a formal process that must be adhered to, and fees are involved. In 1999, Sun submitted Java to the ECMA standards body, but withdrew its J2SE specification later in the year.  (JCP), which allows for input from any industry interested in a profile for a particular type of electronic device. For example, a profile would be created for wireless phones, with the profile defining the configuration to use for wireless phones and the Java APIs that will be available. Any company that had an interest in wireless phones could join the Java Community Process to help determine which configuration to choose and what the Java API would look like for developing Java applications for wireless phones.

J2EE

J2EE is a collection of Java technologies that create a platform for distributed applications. Along with the J2SE (some of the J2EE technologies are actually a part of the Java 2, Standard Edition), J2EE allows for the most complex of multitier software applications to be portable across multiple platforms.

J2EE consists of the following technologies; Enterprise Javabeans (E J-B). An EJB is a component architecture for the development and deployment of object-oriented distributed business applications. Applications written using the EJB architecture are scalable, transactional, and multiuser secure.

Java Servlets. A servlet is a Java application that runs in a Web server.

JavaServer-Pages(JSP). A JavaServer Page is similar to a servlet and allows for the creation of dynamic Web pages.

Java Database Connectivity (database, programming) Java Database Connectivity - (JDBC) Part of the Java Development Kit which defines an application programming interface for Java for standard SQL access to databases from Java programs.

http://java.sun.com/products/jdk/1.1/docs/guide/jdbc/index.html.
 (JDBC (Java DataBase Connectivity) A programming interface that lets Java applications access a database via the SQL language. Since Java interpreters (Java Virtual Machines) are available for all major client platforms, this allows a platform-independent database ). JDBC allows Java applications to access a database.

Extensible Markup Language See XML.

(language, text) Extensible Markup Language - (XML) An initiative from the W3C defining an "extremely simple" dialect of SGML suitable for use on the World-Wide Web.

http://w3.org/XML/.
 (XML). X1ML provides a mechanism for describing data using tags in a platform-independent manner.

Java Naming and Directory Interface The Java Naming and Directory Interface (JNDI) is an API for directory service that allows clients to discover and lookup data and objects via a name. Like all Java APIs that interface with host systems, JNDI is independent of the underlying implementation.  (JNDI (Java Naming and Directory Interface) A programming interface (API) from Sun for connecting Java programs to naming and directory services such as DNS, LDAP and NDS. ). JNDI allows Java applications to access naming services and directory services.

Java Transaction API The Java Transaction API (JTA) is one of the Java EE APIs allowing distributed transactions to be done across multiple XA resources. JTA is a specification developed under the Java Community Process as JSR 907.  (JTA). JTA allows Java applications to access a transaction service.

Java Transaction Service The Java Transaction Service (JTS) is an implementation of the JTA Transaction Manager, AKA TP monitor, that maps onto the OMG Object transaction service used in the CORBA architecture. It uses IIOP to propagate the transactions between multiple JTS transaction managers.  (JTS). JTS defines the implementation of a transaction manager that supports the JTA.

Java Messaging Service (JMS). JMS allows for Java applications to access a message service.

Java IDL (1) (Interface Definition Language) A language used to describe the interface to a routine or function. For example, objects in the CORBA distributed object environment are defined by an IDL, which describes the services performed by the object and how the data . The Java IDL allows Java applications to use CORBA implementations.

JavaMail. Javamail allows Java applications to access an email service.

RMI-IIP-. RMI-IIOP RMI-IIOP Remote Method Invocation Over Internet Inter-Orb Protocol (Rmi Over Iiop)  is for using Remote Method Invocation over the Internet InterOrb Protocol.

Connectors. Connectors allow Java applications to access enterprise information systems.

Java Web Services. Java Web Services allow Java applications to take advantage of the emerging Web services technologies.

Similar to J25E programs run in a JVM, J2EE applications run in a J2EE- compliant application server. The application server implements the J2EE specification, allowing developers to create applications that use any or all of the J2EE technologies, but that still are platform independent. Some of the more popular applications servers are IBM's WebSphere, BEA Systems' WebLogic, and Macromedia's JRun.

The book focuses on the J2SE, the Java 2 Platform, Standard Edition. There is no Java 1. Before Java 2, the versions of Java were referred to by the version of the Java Development Kit JDK). The first release of Java was JDK 1.0, which was released in 1995. The next release was JDK 1.1 with enough changes and additions to JDK 1.0 to make the two versions not backward compatible. With the release of JDK 1.2, Sun started referring to the language as Java 2, and the developer's kit is now called the Standard Developer's Kit (SDK).

The SDK contains many tools for developing and running Java applications, most importantly a compiler and JVM. The current version of the Java 2 SDK Java 2 SDK - Java 2 Software Development Kit  is 1.4, but Sun updates Java 2 frequently; don't be surprised if you find versions 1.5 or beyond on Sun's Web site. No matter what the version is, the SDK is free for developers to download and install.

The SDK can be round at http://java.sun.com/j2se. To download the SDK, click the link for J2SE Downloads, and you will taken to the SDK download page. This page has two columns for each platform: one for the JRE and one for the SDK. JRE stands for Java Runtime Environment, which is what you would download if you wanted to just run Java applications. The JRE is essentially the YVM for your platform.

If you are actually going to write Java programs, you will need the SDK. The SDK contains the/RE plus all the necessary development tools.

Click the SDK that's right for you. For example, if you are going to be using Windows to write your Java programs, click the Windows SDK. Notice that there are versions available for Linux and Solaris as well. You need to agree to Sun's license agreement before downloading.

The SDK is a large download that will take more than an hour for those with a dial-up connection.

After you have downloaded the installation file, execute it to install the SDK. The downloaded file will be unpacked and Install Wizard will begin. You will be prompted to accept Sun's license agreement; then you will be asked to select the folder where the SDK is to be installed.

It is best to install the SDK in the default folder that the Install Wizard displays. For example, for SDK 1.4, the default folder is c\j2sdk1.4.0.4.0. If you do change the install folder, however, be sure not to pick a directory with spaces in the directory name such as Program Files. Spaces in directory names tend to cause problems with the compiler and.

Figure 1.1 shows the step in the Install Wizard where you can choose which components of the SDK to install. If you have plenty of hard drive space, you might as well install all the components; however, if you want to save some hard drive space, you tan choose to not install the Native Interface Header Files, Demos, and the Java Sources

[FIGURE 1.1 OMITTED]

From Java in 60 mins a day. Wiley Tech Publishing. www.wiley.com/compbooks/60minutesaday. ISBN ISBN
abbr.
International Standard Book Number


ISBN International Standard Book Number

ISBN n abbr (= International Standard Book Number) → ISBN m 
 0-471-42314-9
COPYRIGHT 2004 A.P. Publications Ltd.
No portion of this article can be reproduced without the express written permission from the copyright holder.
Copyright 2004, Gale Group. All rights reserved. Gale Group is a Thomson Corporation Company.

 Reader Opinion

Title:

Comment:



 

Article Details
Printer friendly Cite/link Email Feedback
Title Annotation:Teach-In
Author:Raposa, Rich
Publication:Software World
Date:Jan 1, 2004
Words:2397
Previous Article:Email annoyances--a personal view.(Teach-In)
Next Article:Anatomy of an XML document.(Teach-In)



Related Articles
Creating human links: Alicia Jones helps at-risk youth use technology to their advantage. (Black Digerati).(Youth LINKS USA services)
Borland Starter Kits. (Software Tools).
Computer Science. (Senior Division 2002).
Development of non-karaoke mobile music is slow but under wag. (The Pulse 2).
Java-based visualisation and numerical analysis tools. (Tools).
Millions donated to revamp K-12 technology.(Update: education news from schools, businesses, research and government agencies)
Charles River Media.(The Computer Shelf)(Practical Java Game Programming)(Enabling IP Routing With Cisco Routers)(Cisco IP Routing Protocos:...
Sun showcases Digital Campus.(Learning Environments)
Java Reflection in Action.(Brief Article)(Book Review)
Computer science senior section.(Collegiate & Senior Divisions)

Terms of use | Copyright © 2009 Farlex, Inc. | Feedback | For webmasters | Submit articles