204 lines
9.8 KiB
HTML
204 lines
9.8 KiB
HTML
<!--startcut ==========================================================-->
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<title>Java and Linux LG #32</title>
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#A000A0"
|
|
ALINK="#FF0000">
|
|
<!--endcut ============================================================-->
|
|
|
|
<H4>
|
|
"Linux Gazette...<I>making Linux just a little more fun!</I>"
|
|
</H4>
|
|
|
|
<P> <HR> <P>
|
|
<!--===================================================================-->
|
|
|
|
<center>
|
|
<H1><font color="maroon">Java and Linux</font></H1>
|
|
<H4>By <a href="mailto:">Shay Rojansky</a></H4>
|
|
</center>
|
|
<P> <HR> <P>
|
|
|
|
Not long ago, Javasoft celebrated Java's third birthday. Java, once seen
|
|
as merely another way to animate and spice up web pages, has become much
|
|
more than that. Nowadays, well-known software corporations have pledged
|
|
their support to Java, and new Java APIs are being defined in record time. The
|
|
Java technology enables programmers to finally write truly multi-platform
|
|
programs, offers an advanced cross-platform GUI toolkit, embedded
|
|
threading in the language and much more.
|
|
<p>
|
|
At the same time, we are seeing remarkable events in the computer
|
|
software world. Microsoft, the behemoth of the industry, is being seriously
|
|
threatened by anti-trust action from both the Justice Department and 20
|
|
different states. Netscape has released the source code for
|
|
Communicator and may be the first company to break free of Open Software
|
|
prejudice. This has attracted much interest in Open Software from companies
|
|
who have traditionally feared the concept.
|
|
<p>
|
|
What do all of these events mean for the Linux operating system?
|
|
It means we have a window of opportunity. Never before has the
|
|
time been so right. On one hand, the industry is seriously taking
|
|
a look at Linux as an open (and free) OS. Hey, if Netscape is doing
|
|
it with their browser, why not an Open OS? On the other hand, Java
|
|
technology offers a machine-independant way to write applications,
|
|
and much of the industry has rallied behind it.
|
|
<p><HR> <P>
|
|
<h3>Java and the Linux Community</h3>
|
|
<p>
|
|
The Linux community itself, however, has always treated Java with an
|
|
ambivalent attitude. The language that has promised to topple the hegemony
|
|
of Microsoft, a dream like that of any Linux enthusiast, hasn't been
|
|
accepted into the mainstream of Linux development. There are several reasons
|
|
for this.
|
|
<p>
|
|
First and foremost, Java is a proprietary language owned by Sun
|
|
Microsystems. This means that Sun controls every aspect of the language,
|
|
the APIs and their licensing conditions. Tactics by Microsoft, like changing
|
|
APIs in their Java suite J++ and rendering their virtual machine
|
|
incompatible with other Java virtual machines, have forced Sun to seek
|
|
exclusive rights to dub a product ``Java-compatible''. Although this
|
|
may be the only way to fight Microsoft's unfair tactics, never before has a
|
|
language been so much in the hands of a single corporation. The Linux
|
|
community was born much in protest of this kind of ownership.
|
|
<p>
|
|
Second, the multi-platform concept of Java, the Java Virtual Machine
|
|
(JVM), means that programmers feel they are programming for the Java
|
|
environment and not for the Linux environment. This also means that
|
|
it's much more difficult to exploit the features of Linux.
|
|
<p>
|
|
Third, Java is still slow. Many promising enhancements are available such
|
|
as Just-in-Time compilers and Sun's Hotspot (still in beta).
|
|
Java has certainly improved since it was first created, but it
|
|
still requires a powerful platform. The Linux world is
|
|
relatively speed-minded, and one of the main advantages of Linux
|
|
is its ability to run on obsolete hardware.
|
|
<p><HR> <P>
|
|
<h3>The Advantages of Programming in Java</h3>
|
|
<p>
|
|
Despite all these shortcomings in the nature of Java, it
|
|
is the only real challenge made in the last few years to Microsoft's
|
|
rule. It is also an advanced language, written from the ground up
|
|
with modern programming concepts in mind; all the flaws
|
|
C++ retained from C for backwards compatibility are gone in Java,
|
|
along with other complex features (multiple inheritance, for example).
|
|
An automatic garbage collector removes the need to free memory,
|
|
drastically reducing development time. Threads are so embedded
|
|
in the language they become an indispensible tool for the programmer.
|
|
<p>
|
|
I hope Linux developers take a second look at Java as a development language
|
|
and start using it regularly. Some Linux developers have already made
|
|
impressive progress with Java tools, including several Java virtual
|
|
machines (JVMs), several Just-In-Time (JIT) compilers and others. Take a
|
|
look at these if you are considering using your Linux platform for developing
|
|
Java. The Java-Linux resources page can be found at:
|
|
http://www.blackdown.org/java-linux.html
|
|
<p>
|
|
I will now go over some of the key features in JDK 1.1.x. Note that
|
|
the next version, 1.2 is in beta but should be available soon.
|
|
<p><HR> <P>
|
|
<h3>Object Serialization</h3>
|
|
<p>
|
|
Object serializing means taking an object and flattening it into a
|
|
stream of bytes. In practice, this is usually used for two
|
|
things--passing objects through a network and storing objects in files.
|
|
Usually, a programmer who wishes to store a data structure on
|
|
disk has to write a specific algorithm for doing so, which can
|
|
be quite tedious. Java simplifies all this by doing it
|
|
automatically for you. For example, if you have a tree in memory
|
|
and wish to pass it to another Java program on the network, all
|
|
you have to do is to pass the root object--Java will follow the
|
|
pointers and copy the entire tree. If you have special considerations
|
|
(like security), you may design the way the object is serialized.
|
|
<p><HR> <P>
|
|
<h3>Java Foundation Classes (Swing)</h3>
|
|
<p>
|
|
The original AWT, which is the windowing toolkit for Java, was very
|
|
clunky and uncomfortable. Many components were missing and the
|
|
programming model was needlessly painful. The current accepted
|
|
toolkit for Java is code-named Swing. Swing offers a large number
|
|
of lightweight components; they are fully implemented in
|
|
Java but do not use the underlying windowing architecure as
|
|
in AWT. This assures the same functionality across platforms.
|
|
Another appealing feature is the completely pluggable look and feel,
|
|
which lets you switch between Windows and Motif, for example, while
|
|
the program is running. You can also design your own look.
|
|
<p><HR> <P>
|
|
<h3>RMI (Remote Method Invocation)</h3>
|
|
<p>
|
|
RMI is the Java equivalent of CORBA, which is a way to invoke methods
|
|
in objects that are in a different JVM (or even machine). For those
|
|
of you who know the RPC (Remote Procedure Call) frequently used in
|
|
UNIX machines, RMI (and CORBA) are its object-oriented counterparts.
|
|
The concept of ``distributed programming'' has gotten very popular
|
|
lately. In general, it means a very tight integration between programs
|
|
across the network; objects in different machines can talk to each other
|
|
simply by calling each other's methods. This is accomplished by having a
|
|
Java program hold a ``stub'' of a remote object. Then, when a method is invoked
|
|
on that stub, Java transparently sends the request over the network
|
|
and returns the requested value. The extent by which distribution and
|
|
serialization are embedded in Java show the advantage of a
|
|
modern language designed to support these concepts.
|
|
<p><HR> <P>
|
|
<h3>JNI (Java Native Interface)</h3>
|
|
<p>
|
|
Often programmers can get frustrated when they wish to use
|
|
the benefits of Java to do something that is system dependant.
|
|
The JNI allows you to interface with a native-shared object
|
|
and run its functions. This means you can write system-dependant
|
|
code in C (or any other language) and use it from Java. Of course,
|
|
as a result, your program would not be portable unless you supply
|
|
the shared object to all platforms. This could be useful, for example,
|
|
to catch signals in UNIX and to access the registry in Windows.
|
|
<p><HR> <P>
|
|
<h3>JDBC (Java Database Connectivity)</h3>
|
|
<p>
|
|
Java Database Connectivity is an SQL database access interface.
|
|
It provides a database-independent way to perform SQL queries
|
|
on any database that provides JDBC drivers. Currently, many popular
|
|
databases do, and those that don't can still be accessed via
|
|
the JDBC-ODBC bridge, which allows you to use ODBC drivers instead.
|
|
For a list of database drivers see:
|
|
http://java.sun.com/products/jdbc/jdbc.drivers.html.
|
|
<p>
|
|
Take a good look at Java. If we could manage to separate the
|
|
applications from the operating systems running them, we'd have the
|
|
freedom to choose shich OS we like best. Although in spirit the Linux
|
|
community has a ``renegade'' non-conformist element in it, Java has a great
|
|
potential and deserves our attention. The Linux-Java combination can turn
|
|
into a winning one.
|
|
<p>
|
|
<h3>Java Resources</h3>
|
|
<p>
|
|
Java home: <A HREF="http://java.sun.com/">"http://java.sun.com/</A>
|
|
<p>
|
|
Java developer connection (free registration):
|
|
<A HREF="http://java.sun.com/jdc/">http://java.sun.com/jdc/</A>
|
|
<p>
|
|
Swing (JFC): <A HREF="http://java.sun.com/products/jfc/index.html">
|
|
http://java.sun.com/products/jfc/index.html</A>
|
|
<p>
|
|
Java for Linux: <A HREF="http://www.blackdown.org/java-linux.html">
|
|
http://www.blackdown.org/java-linux.html</A>
|
|
|
|
<!--===================================================================-->
|
|
<P> <hr> <P>
|
|
<center><H5>Copyright © 1998, Shay Rojansky <BR>
|
|
Published in Issue 32 of <i>Linux Gazette</i>, September 1998</H5></center>
|
|
|
|
<!--===================================================================-->
|
|
<P> <hr> <P>
|
|
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
|
|
ALT="[ TABLE OF CONTENTS ]"></A>
|
|
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
|
|
ALT="[ FRONT PAGE ]"></A>
|
|
<A HREF="./vermeer.html"><IMG SRC="../gx/back2.gif"
|
|
ALT=" Back "></A>
|
|
<A HREF="./jenkins1.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
|
|
<P> <hr> <P>
|
|
<!--startcut ==========================================================-->
|
|
</BODY>
|
|
</HTML>
|
|
<!--endcut ============================================================-->
|