★ wanayoo — archive 1999 http://www.webdeveloper.com/java/java_programming_grounds_up.htmlNouvelle recherche | Portail wanayoo
internet.com

Go to WebDeveloper Home

Seek and you shall

or search all of internet.com
Looking for a Site Map?
Vote for WD!
Please keep
voting for us
as a Top 100
Web site!

The Web Developer Network
WebDeveloper.com
Streaming Media World
WebReference.com
Web Developer's Virtual Library
BrowserWatch
Java Boutique
Web Developer's Journal
JavaScript Source
ScriptSearch
Web Developer Forums
Web Developer News

internet.com
Internet News
Internet Stocks
Internet Technology
Web Developer
Internet Marketing
ISP
Downloads
Internet Resources
International

Search internet.com
Advertising Info
Corporate Info
Internet Trade Shows

internet.commerce
Be an Affiliate
Be a Partner
Software Store
Computer Help
Register a Domain
Be Domain Registrar
e-solutions
Internet Jobs
A/V Network
Map Your Website
Rent E-mail Lists
Bookstore
Press Release dist.
Sell Ad Space
Internet Research
Venture Capital
Web Publishing
Build Your Intranet
Expert Advice
Get e-Biz Intell.
Content for Websites

  Let internet.com work for you!
J A V A  T U T O R I A L
WebDeveloper.com

Java Programming...
From the Grounds Up

by Mark C. Reynolds

With Java, it's possible to write some very sophisticated applets with a relatively small amount of code. Here's how.

Wildly popular due to its interactive multimedia capabilities, Java programming leads the list of Internet development skills in current commercial demand. In this first half of our two-part tutorial on Java applet development, we explore the essentials of Java's components. These include how Java development tools relate to each other and--most importantly--how they are used to provide content that executes on the client side instead of on your server.

Before Sun Microsystems introduced Java, most Web interactivity was accomplished via CGI (Common Gateway Interface) scripting. This is frequently utilized in forms or guestbooks where users type entries into text fields, then submit this information via their browser back to a host server. The host server then passes the information to an external program running on the Web server's machine. The output of this external program is then passed from the server back to the browser. CGIs must execute at least one round trip from the browser to the server and back.

In contrast, when a Java-compatible browser accesses a Java-powered page, an applet--a small program written in Java--is copied to the browser's machine and executes there. It does not execute on the server the way a CGI program does. This local execution makes possible a much greater level of Web interaction and multimedia effects, unhampered by HTML restrictions or network bandwidth. Java programs can display slick animations, invite users to play games, show step-by-step tutorial instructions, or run demonstration versions of computer software. When a browser accesses a standard HTML page, the result is usually a static display. When it runs a Java applet, however, the results are limited only by the creativity of the applet's developer. The applet is a nearly independent application running within the browser.

Getting Started

Java is an object-oriented programming language that resembles a simplified form of C++. Java code displays graphics, accesses the network, and interfaces with users via a set of capabilities--known as classes--that define similar states and common methods for an object's behavior. Unlike other programming languages, though, Java programs are not compiled into machine code; instead, they are converted into an architecture-neutral bytecode format. This collection of bytes represents the code for an abstract Java virtual machine (VM). In order for these bytes to execute on a physical machine, a Java interpreter running on that physical machine must translate those bytes into local actions, such as printing a string or drawing a button.

To run Java applets, you'll need a Java-enabled browser (such as Sun's HotJava, Netscape 2.0 or greater, or Internet Explorer 3.0 or greater) or you can use the appletviewer utility in Sun's Java Development Kit (JDK). The JDK also includes an interpreter for standalone Java applications (called simply java), as well as a debugger and compiler, called jdbg and javac respectively.

Java applets use a subset of the full Java VM, with a variety of features disabled for security reasons. You can add Java applets to your Web pages with the <APPLET> tag, which can include attributes for the applet's height, width, and other parameters. Java-capable browsers treat Java applets like other media objects in an HTML document: they are loaded with the rest of the page, then verified and executed.

Java Classes and Methods

Java utilizes the basic object technology found in C++. In a nutshell, the Java language supports the idea of data packaging, or encapsulation, through its mechanism. A Java class is an association between data elements and/or functions, much like an extended struct in C (or a C++ class). In fact, there are no structs in Java at all; the mechanism of grouping together similar elements is achieved only by creating a class. The functional members of a class are referred to as the class methods. Just as a C struct may contain other structs within it, a Java class may be built on top of another class--although only one at a time--and inherit that class's behaviors as well.

Java has its own syntax for describing methods and classes. It supports public class members, which are visible outside the class; protected members, which are visible only within the class and its subclasses; and private members, which are only visible within that particular class. Java supports abstract (virtual) classes, in which some or all of the member functions are declared, but not defined--they have no function body, so that only subclasses which fully define those functions may be used.

If you have some experience with C++ programming, many of these concepts will be familiar to you. However, there are several striking differences between C++ and Java. Much of the implicit behavior that C++ takes for granted is absent in Java. For example, there are no default constructors: a Java program must explicitly call the operator new to create a new instance of a class. In addition, arithmetic operators such as "+" or "= =" may not overload in Java. There is no way for the programmer to extend the behavior of "+" beyond what Java provides intrinsically. Another highly visible departure from C and C++ is that there are no pointers (and logically, no pointer arithmetic) in Java.

[ Click here to move to the next part of the article (and some real code!) ]

Fast Jump to Anywhere on WebDeveloper.com:

Free Internet Marketing info!



Copyright © 1999 internet.com Corporation
All Rights Reserved. Legal Notices.
Contact the WebDeveloper.com staff

Last modified: Fri Sep 24 17:57:44 EDT 1999

http://www.internet.com

 

Refresh Daily
Join Editor-in-Chief David Fiedler The Editor With No Time and find truth, justice, and a clue or two.


Browse by Category
[ Site Map ]

ActiveX / VBscript
Animated GIF Archive
Browsers
CGI / Perl
Database Connectivity
Design / Graphics
E-Commerce
HTML-Advanced: DHTML, CSS
HTML / Site Authoring Tools
Intranet/Groupware
Java
JavaScript
Multimedia: Audio / Video / Streaming Technologies
Opinions
Refresh Daily: Editorial Column
Security
Servers & Server Tools
Site Design / Graphics
Site Management / Marketing / Log File Analysis
Tutorials
VRML / 3D
XML