Copy Link
Add to Bookmark
Report

Java Coffee Break Newsletter Volume 3 Issue 01

         Java Coffee Break Newsletter Volume 3, Issue 1 
http://www.javacoffeebreak.com/
ISSN 1442-3790

=================================================================

In this issue

* Java in the news
* Book Review - Distributed Programming with Java
* Book Review - The Complete Java 2 Certification Study Guide
* Inside Java Column : Inside the Java Programming Language
* Q&A : How do I get parameters from a HTML form when using
servlets?
* Q&A : How do I debug my Java applets to see what's going
wrong?

=================================================================

In the News

Here are a selection of recent news items that may be of
interest to Java developers.

/*/ Visual J++ development spun off to Rational - NOT!

Postings on the Java Lobby site, and an article linked
from one posting, indicated that Rational, developers of
leading-edge object oriented design tools such as Rational
Rose, were to continue the development of Microsoft's
Visual J++ tool.

Visual J++ has taken a beating over the past few years,
from stiff competition over the Java development tool
marketplace. Borland/Inprise JBuilder, IBM's Visual Age
for Java, and Symantec's Visual Cafe have offered tough
competition, and problems with portability when using the
Microsoft WFC and J/Direct have weakened public perception
of J++. Yet Visual J++ remains an excellent code editor
with a lightning fast complier. Visual J++ isn't down for
the count yet.

It seems that rumors of J++'s death were greatly exagerated.
Visual J++ is not being cancelled, nor is it leaving the
Microsoft stable. This is reassuring news for programmers
using J++ for application development. However, the future
of Visual J++ still isn't clear, and there is the possibility
that it may not stay as part of the Visual Studio range,
according to a PC Week report. For more information see
the article at
http://www.zdnet.com/pcweek/stories/news/0,4153,2407600,00.html

/*/ Java Coffee Break needs YOUR help!

We'd like all of our subscribers to complete a brief, two
minute survey, which will help us secure advertising. This
advertising pays for the articles and advice offered freely
from our website, and our monthly newsletter. If you haven't
already, we'd love you to participate in this survey.
Individual survey responses are aggregated to form a broad
demographic profile of the typical user, for our advertisers.

Survey available at
http://www.javacoffeebreak.com/survey.html

/*/ Inprise releases JBuilder 3 Foundation Edition

A new, free, version of Borland JBuilder 3 has been released.
This is a severely cut down version of the product, however.
Support for servlets is cut, but applets and applications
are supported. Details are available from

http://www.inprise.com/jbuilder/foundation/

=================================================================


Book Review - Distributed Programming with Java

Author : Qusay H. Mahmoud
Publisher : Manning
ISBN : 1884777651
Experience: Intermediate - Advanced

Distributed Programming with Java aims to teach the reader how to
build distributed services using a variety of technologies,
including sockets, remote-method invocation (RMI), and the Common
Object Request Broker Architecture (CORBA). While many
programmers will be familiar with sockets, the other two
technologies are incredibly powerful tools for creating
distributed applications. RMI is for execution of Java methods
remotely, similar to the old remote-procedure call technology,
but with an object-orientated twist. CORBA is a more universal
system, which allows object methods written in any language (such
as C++, Java or Ada) to be called remotely. Incredible stuff, but
incredibly complex.

That's where Distributed Programming with Java comes in. It
teaches the theory of remote-method invocation and CORBA, and
gives you practical examples in Java. There are also chapters on
socket programming and mobile agency. The socket chapters are
good as a refresher course for those who have already done
network programming, but are a poor substitute for the coverage
offered by other books, such as the excellent Java Network
Programming (also published by Manning). As for the Mobile Agents
chapters, while they are interesting reading, they may not be
generally applicable to all developers. If you're buying the
book, you're really buying it for the RMI and CORBA coverage.

The author clearly knows his remote-method invocation - showing
you how to digitally sign your RMI code, to create distributed
services with callbacks, and how to use Secure Sockets Layer
(SSL) to protect your RMI applications from prying eyes. The
later requires the new Java 2 platform, which includes SSL
support. 

When it comes to the CORBA chapters, however, I'm a little
disappointed. The author chooses to use the VisiBroker CORBA
implementation, and completely ignores the CORBA IDL support in
the new Java 2 platform. I suspect that these chapters may have
been written prior to the release of the Java 2 platform, and
there is explanation for the choice of VisiBroker. Nor, for that
matter, is there much help in downloading or installing the
VisiBroker software (a copy on CD along with source would
certainly have been nice). However, the technical coverage of
CORBA theory is very well done, and the chapters on basic CORBA
theory, IDL-to-Java mapping, and IDL inheritance could be used no
matter what choice of CORBA implementation you make.

For its mobile agent coverage, the author chose ObjectSpace's
Voyager system. There are a couple of paragraphs on alternate
mobile agent systems, such as Telescript/Odyssey and Aglets, but
the coverage of these is superficial to say the least. However,
it does give very good coverage of mobile agents using Voyager,
and how to integrate Voyager with CORBA.

If you're interested in distributed systems using remote-method
invocation or CORBA, then Distributed Programming with Java makes
a great guide to the subject. It's filled with practical
examples, and good coverage of the theory. However, the sections
on socket and mobile agent programming aren't designed for
beginners, and won't suit all tastes. Nonetheless, the RMI and
CORBA coverage alone makes it worthwhile as a reference, and if
you have an interest in mobile agents that comes as a bonus.

For more information about this title, or to order it, visit
http://www.davidreilly.com/goto.cgi?isbn=1884777651

=================================================================

Book Review - The Complete Java 2 Certification Study Guide

Author : Roberts, Heller & Ernest
Publisher : Sybex
ISBN : 0782127002
Experience: Intermediate - Advanced

Review courtesy of Amazon.com
Sun Microsystems (the creator of the Java programming language)
has two Java Certification Exams -- one for programmers and one
for developers. This Study Guide is the ultimate authority for
both of the Sun Certification Tests! The lead author of Sybex's
The Complete Java 2 Certification Study Guide actually developed
the exams for Sun. Not only was Roberts the key player in the
concept, strategy, and implementation of the test guidelines, he
also developed the questions. The Study Guide is organized
according to the exam objectives defined by Sun. Every single
objective is covered, reinforced with sample questions and
annotated answers. The book has a stamp of approval from the Sun
Education Team and includes a CD with an exclusive Java exam test
engine.


Additional information

This guide aids in the preparation for the Sun Certified Java
Programmer and Sun Certified Java Developers examinations. These
examinations cost an additional fee, and require a 70% score to
pass. You are highly advised to purchase a study guide, or seek
out a professional training course, before sitting for these
exams. As a Sun Certified Java Programmer myself, I can assure
you that the exams are grueling, and you need to prepare first!
For more information, see our special article
(http://www.javacoffeebreak.com/articles/certification/) on
passing the Sun Certification Exams. -- David Reilly


For more information about this title, or to order it, visit
http://www.davidreilly.com/goto.cgi?isbn=0471345342

=================================================================

Inside Java :
The Java Programming Language


Inside Java offers a glimpse behind the Java
platform, and related technologies. In this
month's column, I'll show you an overview
of the Java programming language.

Java - an island of Indonesia, a type of coffee, and a
programming language. Three very different meanings, each in
varying degrees of importance. Most programmers, though, are
interested in the Java programming language. In just a few short
years (since late 1995), Java has taken the software community by
storm. Its phenomenal success has made Java the fastest growing
programming language ever. There's plenty of hype about Java, and
what it can do. Many programmers, and end-users, are confused
about exactly what it is, and what Java offers.


Java is a revolutionary language

The properties that make Java so attractive are present in other
programming languages. Many languages are ideally suited for
certain types of applications, even more so than Java. But Java
brings all these properties together, in one language. This is a
revolutionary jump forward for the software industry.

Let's look at some of the properties in more detail: -

* object-oriented
* portable
* multi-threaded
* automatic garbage collection
* secure
* network and "Internet" aware
* simplicity and ease-of-use


Object-oriented

Many older languages, like C and Pascal, were procedural
languages. Procedures (also called functions) were blocks of code
that were part of a module or application. Procedures passed
parameters (primitive data types like integers, characters,
strings, and floating point numbers). Code was treated separately
to data. You had to pass around data structures, and procedures
could easily modify their contents. This was a source of
problems, as parts of a program could have unforeseen effects in
other parts. Tracking down which procedure was at fault wasted a
great deal of time and effort, particularly with large programs.

In some procedural language, you could even obtain the memory
location of a data structure. Armed with this location, you could
read and write to the data at a later time, or accidentally
overwrite the contents.

Java is an object-oriented language. An object-oriented language
deals with objects. Objects contain both data (member variables)
and code (methods). Each object belongs to a particular class,
which is a blueprint describing the member variables and methods
an object offers. In Java, almost every variable is an object of
some type or another - even strings. Object-oriented programming
requires a different way of thinking, but is a better way to
design software than procedural programming.

There are many popular object-oriented languages available today.
Some like Smalltalk and Java are designed from the beginning to
be object-oriented. Others, like C++, are partially
object-oriented, and partially procedural. In C++, you can still
overwrite the contents of data structures and objects, causing
the application to crash. Thankfully, Java prohibits direct
access to memory contents, leading to a more robust system.


Portable

Most programming languages are designed for a specific operating
system and processor architecture. When source code (the
instructions that make up a program) are compiled, it is
converted to machine code which can be executed only on one type
of machine. This process produces native code, which is extremely
fast.

Another type of language is one that is interpreted. Interpreted
code is read by a software application (the interpreter), which
performs the specified actions. Interpreted code often doesn't
need to be compiled - it is translated as it is run. For this
reason, interpreted code is quite slow, but often portable across
different operating systems and processor architectures.

Java takes the best of both techniques. Java code is compiled
into a platform-neutral machine code, which is called Java
bytecode. A special type of interpreter, known as a Java Virtual
Machine (JVM), reads the bytecode, and processes it. Figure One
shows a disassembly of a small Java application. The bytecode,
indicated by the arrow, is represented in text form here, but
when compiled it is represented as bytes to conserve space.

* Figure One - Bytecode disassembly for "HelloWorld"

The approach Java takes offers some big advantages over other
interpreted languages. Firstly, the source code is protected from
view and modification - only the bytecode needs to be made
available to users. Secondly, security mechanisms can scan
bytecode for signs of modification or harmful code, complimenting
the other security mechanisms of Java. Most of all though, it
means that Java code can be compiled once, and run on any machine
and operating system combination that supports a Java Virtual
Machine (JVM). Java can run on Unix, Windows, Macintosh, and even
the Palm Pilot. Java can even run inside a web browser, or a web
server. Being portable means that the application only has to be
written once - and can then execute on a wider range of machines.
This saves a lot of time, and money.


Multi-threaded

If you've ever written complex applications in C, or PERL, you'll
probably have come across the concept of multiple processes
before. An application can split itself into separate copies,
which run concurrently. Each copy replicates code and data,
resulting in increased memory consumption. Getting the copies to
talk together can be complex, and frustrating. Creating each
process involves a call to the operating system, which consumes
extra CPU time as well.

A better model is to use multiple threads of execution, referred
to as threads for short. Threads can share data and code, making
it easier to share data between thread instances. They also use
less memory and CPU overhead. Some languages, like C++, have
support for threads, but they are complex to use. Java has
support for multiple threads of execution built right into the
language. Threads require a different way of thinking, but can be
understood very quickly. Thread support in Java is very simple to
use, and the use of threads in applications and applets is quite
commonplace.


Automatic garbage collection

No, we're not talking about taking out the trash (though a
computer that could literally do that would be kind of neat). The
term garbage collection refers to the reclamation of unused
memory space. When applications create objects, the JVM allocates
memory space for their storage. When the object is no longer
needed (no reference to the object exists), the memory space can
be reclaimed for later use. 

Languages like C++ force programmers to allocate and deallocate
memory for data and objects manually. This adds extra complexity,
but also causes another problem - memory leaks. When programmers
forget to deallocate memory, the amount of free memory available
is decreased. Programs that frequently create and destroy objects
may eventually find that there is no memory left. In Java, the
programmer is free from such worries, as the JVM will perform
automatic garbage collection of objects.


Secure

Security is a big issue with Java. Since Java applets are
downloaded remotely, and executed in a browser, security is of
great concern. We wouldn't want applets reading our personal
documents, deleting files, or causing mischief. At the API level,
there are strong security restrictions on file and network access
for applets, as well as support for digital signatures to verify
the integrity of downloaded code.

At the bytecode level, checks are made for obvious hacks, such as
stack manipulation or invalid bytecode. The strong security
mechanisms in Java help to protect against inadvertent or
intentional security violations, but it is important to remember
that no system is perfect. The weakest link in the chain is the
Java Virtual Machine on which it is run - a JVM with known
security weaknesses can be prone to attack. It is also worth
noting that while there have been a few identified weaknesses in
JVMs, they are rare, and usually fixed quickly. 


Network and "Internet" aware

Java was designed to be "Internet" aware, and to support network
programming. The Java API provides extensive network support,
from sockets and IP addresses, to URLs and HTTP. It's extremely
easy to write network applications in Java, and the code is
completely portable between platforms. In languages like C/C++,
the networking code must be re-written for different operating
systems, and is usually more complex. The networking support of
Java saves a lot of time, and effort.

Java also includes support for more exotic network programming,
such as remote-method invocation (RMI), CORBA and Jini. These
distributed systems technologies make Java an attractive choice
for large distributed systems.


Simplicity and ease-of-use

Java draws its roots from the C++ language. C++ is widely used,
and very popular. Yet it is regarded as a complex language, with
features like multiple-inheritance, templates and pointers that
are counter-productive. Java, on the other hand, is closer to a
"pure" object-oriented language. Access to memory pointers is
removed, and object-references are used instead. Support for
multiple-inheritance has been removed, which lends itself to
clearer and simpler class designs. The I/O and network library is
very easy to use, and the Java API provides developers with lots
of time-saving code (such as networking and data-structures).
After using Java for awhile, most developers are reluctant to
return to other languages, because of the simplicity and elegance
of Java.


Summary

Java provides developers with many advantages. While most of
these are present in other languages, Java combines all of these
together into one language. The rapid growth of Java has been
nothing short of phenomenal, and shows no signs (yet!) of slowing
down. In next month's column, I'll talk more about the heart of
Java - the Java Virtual Machine.

For diagrams, and back issues of this column, visit
http://www.javacoffeebreak.com/articles/inside_java/

=================================================================

Q&A: How do I get parameters from a HTML
form when using servlets?

When extending javax.servlet.http.HttpServlet, you should
override either of the following two methods: -

public void doGet(HttpServletRequest req,
HttpServletResponse res)
public void doPost(HttpServletRequest req,
HttpServletResponse res)

Both of these methods accept as a parameter a HttpServletRequest
instance. This allows the servlet to obtain information about the
browser request, including the parameters passed to the servlet.

By using the String getParameter(String) method, you can request
any parameter you need. If the parameter is not present, a null
value will be returned.

=================================================================

Q&A: How do I debug my Java applets to see
what's going wrong?

Often, when an applet behaves strangely or fails to work, the
problem is hard to diagnose. Many applets behave fine under
Netscape Navigator, only to fail under Internet Explorer (or vice
versa). Sometimes a different Java Virtual Machine (JVM) will
have less tolerance for a bug, and other times the fault lies in
the actual JVM implementation.

The lack of information provided by the browser can be
frustrating. However, there is a way to display a debugging
console, which will provide developers with additional
information. For example, an uncaught exception will generate an
exception trace, telling you which method and which exception
were involved. Both the later versions of Netscape Communicator
and Internet Explorer support these debugging consoles.


To view the Java Console in Netscape Communicator

Load any page with an applet, and then select the following menu
option "Communicator -> Tools -> Java Console"


To view the Java Console in Netscape Communicator

First, you must ensure that the Java console is enabled. Make
sure that the "Tools -> Options -> Advanced -> Java Console
Enabled" checkbox is checked.

Next, load any page with an applet, and then select the following
menu option "View -> Java Console"

Both of these consoles provide useful debugging information,
which can assist developers in tracking down that pesky bug.

=================================================================

The Java Coffee Break Newsletter is only sent out to email
subscribers who have requested it, and to readers of the
comp.lang.java.programmer and comp.lang.java.help
newsgroups.

If you'd like to receive our newsletter, and get the latest
Java news, tips and articles from our site, then get your FREE
subscription & back issues from

http://www.javacoffeebreak.com/newsletter/

If you are an email subscriber and no longer wish to receive
the JCB Newsletter, please unsubscribe by emailing
javacoffeebreak-unsubscribe@listbot.com

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT