iJUGGL – The Independent Java User Group Greater London

  • Independent – We are not affiliated or run by any other user group or vendor
  • Java – is the language from Sun
  • User Group – We are just a bunch of people who are interested in exchanging information about Java / Greater London – The group cover the Greater London region but we welcome participation from anywhere.

Why JAVA?

Many years ago, when Pascal seemed like a rather good idea, the structured programming paradigm shift was, over a period of years, adopted as the educational model by the majority of higher education computing departments. This was accomplished for very sound and well understood pedagogic reasons. It resulted in the widespread adoption of Pascal as a first language, though not as a base language, in the majority of institutions. In time Pascal was replaced with other structured languages such as Ada or Modula 2 although, even today, there is evidence [McCauley 97] that Pascal still retains its pre-eminence.

Several years ago, when Object Orientation seemed like a rather good idea, many departments adopted C++ as a first language. This was despite the compelling evidence and overwhelming opinion that C, and hence C++, was totally unsuitable for novice developers. The impression was left that these departments had followed this path in pursuance of C++’s commercial importance. This impression was confirmed when it emerged [Culwin 95] that these courses were overwhelmingly procedural with a very minor consideration of Object Orientation tagged on at the end.

This year, in the wake of the World Wide Web, Java might seem to be a rather good idea. The rate at which Java has generated interest, both in academia and in commerce, is unprecedented and the reasons underlying this interest have yet to be fully understood. It was against this background that the “Java in the Computing Curriculum” conference was held at South Bank University: London under the aegis of CTI Computing in February 1997.

If there is any common theme to the papers collected from this conference in this journal it is that the paradigm shift in educational practice towards Object Orientation, which should have been caused by the adoption of C++, will be forced by the adoption of Java. Hence, although there was no keynote paper I would commend Phil McLaughlin’s paper ‘Oh, by the way, Java is Object Oriented …‘ to this position. However a fundamental understanding of Java, particularly of the ways in which it differs from C++, is still required for many people and Barry Cornelius’s tutorial ‘A Taste of Java‘ is an excellent introduction to the language.

Two previous software development environments, Apple’s Hypercard and Microsoft’s Visual Basic, have had an impact somewhat comparable to that of Java though, in retrospect, much more muted. Both of these products rapidly gained a reputation for allowing, or even encouraging, the hacking together of applications with a Graphical User Interface whose functionality was flawed and whose usability was underwhelming. There is no guarantee that developers using Java will not fall into a similar trap; but Tim Ball’s paper ‘Interfacing with the AWT‘, subtitled ‘Software Engineering and the Abstract Window Toolkit‘ provides a rigorous approach to the engineering of GUIs which should be required reading for all Java developers.

Experience gained from actually using Java in the classroom was, at the time of the conference, very thin on the ground. The paper by Roger Garside, ‘Teaching Java at Lancaster‘ presents the experience of using Java as a first language in the 1996/7 session. The paper from Alan Battersby, ‘Initial experience of using Java in a Distributed Computing Module‘, probably portends a large number of papers which describe Java’s advantages in various area’s of curriculum. Finally the paper by Chris Wallace, Peter Martin and Bob Lang, ‘Not whether Java but how Java‘, returns to the theme of Java as a first language and advocates a careful introduction of procedural concepts before considering object orientation. The final paper in this Journal, by Fintan Culwin, presents the results of an opinion sampling workshop on Java held at the 4th Dublin conference which resulted in the Java conference being called.

We live in interesting times and in the computing industry in very interesting times. For good reasons or bad the C style of syntax has become the lingua franca of the computing industry and, as with mediaeval academics and Latin, a working knowledge of C syntax is essential to participate in the software development industry. Latin existed, and exists, in many forms and dialects ranging from pig Latin, through ecclesiastical Latin through to classical Latin. The academic advantages of learning Latin were, and are, related only to classical Latin because of the purity of its structure and the influence which it had upon the English language.

I would contend that, if for no other reason, Java, by removing some of the syntactic absurdities of C++ should replace C++ as the dominant language of undergraduate software development education. The side effects of this transition will be to enable the paradigm shift from structured to object oriented programming, which is already long overdue. A further consequence of this, as Alan Battersby’s paper presages, will be to de-obsfucate many arcane areas of instruction. The educational use of Java is still in its infancy and many of the pitfalls have yet to be discovered, accordingly we hope to reconvene the Java conference early in 1998 when, hopefully, many more educators will be able to report upon practical experience.

What is JAVA?

Java is a set of computer software and specifications developed by James Gosling at Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers. Java applets, which are less common than standalone Java applications, were commonly run in secure, sandboxed environments to provide many features of native applications through being embedded in HTML pages.

Writing in the Java programming language is the primary way to produce code that will be deployed as byte code in a Java virtual machine (JVM); byte code compilers are also available for other languages, including Ada, JavaScript, Python, and Ruby. In addition, several languages have been designed to run natively on the JVM, including Clojure, Groovy, and Scala. Java syntax borrows heavily from C and C++, but object-oriented features are modeled after Smalltalk and Objective-C.[12] Java eschews certain low-level constructs such as pointers and has a very simple memory model where objects are allocated on the heap (while some implementations e.g. all currently supported by Oracle, may use escape analysis optimization to allocate on the stack instead) and all variables of object types are references. Memory management is handled through integrated automatic garbage collection performed by the JVM.

On November 13, 2006, Sun Microsystems made the bulk of its implementation of Java available under the GNU General Public License (GPL).[13][14]

The latest version is Java 15, released in September 2020. Java, being an Open Source platform has many distributors, like Amazon, IBM, Azul Systems, AdoptOpenJDK, and many others with free and commercial support distributions (Amazon Correto, Zulu, AdoptOpenJDK, Liberica, etc.), but regarding the Oracle distribution, Java 11, is the currently supported long-term support (LTS) version (“Oracle Customers will receive Oracle Premier Support”), released on September 25, 2018. Oracle (and others) “highly recommend that you uninstall older versions of Java”, because of serious risks due to unresolved security issues. Since Java 9 (and 10) is no longer supported, Oracle advises its users to “immediately transition” to Java 11 (Java 15 is also a non-LTS option). Oracle released the last free-for-commercial-use public update for the legacy Java 8 LTS in January 2019, and will continue to support Java 8 with public updates for personal use indefinitely. Oracle extended support for Java 6 ended in December 2018.

A Taste of Java

Barry Cornelius
IT Service, University of Durham, DURHAM DH1 3LE

1. Introduction

1.1 What is Java?

Java is an object-oriented programming language developed by Sun Microsystems. It has: strong-typing, garbage collection, multithreading, exception handling and no architecture- dependent constructs. It does not have: structs, unions, pointer arithmetic, operator-overloading and multiple inheritance. It is accompanied by many packages (collections of classes) including one for building GUIs.

1.2 How is it executed?

Unlike most programming languages, Java source code is not compiled into native code. Instead, a Java compiler translates Java source code into an architecturally-neutral intermediate form known as bytecode. Instructions in this bytecode are interpreted by a Java interpreter.

Sun’s Java Developers Kit (JDK) includes a compiler and interpreter. They provide (free of charge) versions for Solaris 2.x (both sparc and x86), for Windows 95, for Windows NT and for MacOS System 7 (and above). Currently, the version of the JDK that most people use is JDK 1.0.2. However, the final release of JDK 1.1 is now available. The next release (JDK 1.1.1) will be a bug-fix release. Both JDK 1.0.2 and JDK 1.1 can be downloaded from:

http://www.javasoft.com/nav/download/index.html
1.3 What are Java applications?

A Java application is a conventional program. It must have a method called main.

Suppose that the file HWTion.java contains the Java application:

public class HWTion {
public static void main(String[ ] args) {
System.out.println(“Hello World!”);
}
}

It can be compiled by using the Unix/MS-DOS command:

javac HWTion.java
This command produces a file of bytecodes in the file HWTion.class. This file can then be interpreted (i.e., executed) by using the command:

java HWTion

1.4 What are Java applets?

A Java applet is Java source code whose bytecodes will be executed as part of viewing a WWW page. The applet’s author compiles the Java source code into bytecodes. These bytecodes will be downloaded from their author’s site by a WWW browser when the WWW page is visited. So, the browser needs to have a Java interpreter to interpret the bytecodes. This is true for WWW browsers that are Java-aware, e.g., Sun’s HotJava, Microsoft’s Internet Explorer or Netscape’s Navigator.

Until recently, Netscape Navigator for Windows 3.1 did not support Java. However, a beta version is now available. For more details, see:

http://home.netscape.com/comprod/products/navigator/version_ 3.0/winjava.html
There is also a version of Internet Explorer (3.0a) that supports Java on Windows 3.1:

http://www.microsoft.com/ie/product/win31/java16.htm
Sun’s JDK includes an appletviewer that can be used if you do not have a Java-aware WWW browser.

Suppose the file HWLet.java contains the Java applet:

import java.awt.Graphics;
import java.applet.Applet;
public class HWLet extends Applet {
public void paint(Graphics rGraphics) {
rGraphics.drawString(“Hello World!”,
50,25);
}
}
It can be compiled by using the command:

javac HWLet.java

This command produces the file HWLet.class.

When a browser reads the WWW page given below, it finds that it has to retrieve the file HWLet.class. When the bytecodes in this file arrive, it can interpret them.

HTML>
HEAD>
TITLE> HWLet example /TITLE>
/HEAD>
BODY>
Before the output from the applet.
APPLET CODE=”HWLet.class” WIDTH=150 HEIGHT=25>
/APPLET>
After the output from the applet.
/BODY>
/HTML>

* Please note that a number of less than symbols are missing from the above code so that the code can be viewed by you.

You can access a WWW page containing the above HTML instructions by using the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/HWLet.html
1.5 Some real examples of applications

One of the first large applications was the WWW browser produced by Sun called HotJava. So, all of the code of HotJava is written in the Java programming language. For more details, see:

http://www.javasoft.com/HotJava/
Sun has produced an IDE (Integrated Development Environment) for Java written in Java called Java Workshop:

http://www.sun.com/developer-products/java/
Borland’s AppExpert and Debugger for Java are written in Java:

http://www.borland.com/jbuilder/introguide/java1_1.html
Two groups have produced WWW servers written in Java. Sun has produced Java Web Server (formerly known as Jeeves) at:

http://www.javasoft.com/products/java-server/index.html
and the World Wide Web Consortium has produced Jigsaw at:

http://www.w3.org/pub/WWW/Jigsaw/
1.6 Some real examples of applets

A pre-beta release of Corel Office for Java, a suite of office productivity applications (including Quattro Pro and WordPerfect) written entirely in Java, is obtainable from:

http://officeforjava.corel.com
Applix’s product Anyware Office is a complete suite of applications (written in Java) including a WYSIWYG word processor, a 3-D GUI spreadsheet, business graphics and an e-mail client. The same applications can be executed on “Webtops, NCs, Windows 95, NT and UNIX desktops and servers”. It costs $295 per concurrent user.

1.7 A digression: what is JavaScript?

Here is a WWW page that includes some source code written in JavaScript:

HTML> HEAD> TITLE> Square demo /TITLE> /HEAD>
BODY>
P> Start. /P>
SCRIPT LANGUAGE=”JavaScript”>
!— hide this script from some browsers
function mysquare(myarg) {
document.write(“P>Hello again/P>”);
document.write(“P> code>myarg /code> is”,
myarg, “/P>”);
return myarg*myarg;
} ;
document.write(“P>Value returned is: “,
mysquare(7), “/P>”);
// end of hide —>
/SCRIPT>
P> Finish. /P>
/BODY> /HTML>
* Please note that a number of less than symbols are missing from the above code so that the code can be viewed by you.

JavaScript is another programming language. You put JavaScript code in HTML documents with a <SCRIPT> tag. The JavaScript code is not compiled: instead, it is interpreted by a JavaScript-aware WWW browser. Netscape Navigator (including the Windows 3.x version) understands JavaScript.

JavaScript has most of Java’s expression syntax and basic control flow constructs, but it does not have Java’s strong type checking and static typing. You cannot write your own classes. So, JavaScript is not as powerful as Java. It is confusing for Java to be included as part of the name JavaScript.

2. The Java language

2.1 What’s been taken out from C/C++?

#define, typedef, enum, union, struct, sizeof, goto, pointer arithmetic
most uses of const: some uses renamed as final
global variables – every variable has to belong to a class (or is a local variable)
standalone functions – every function has to be a method of a class
optional arguments, operator overloading, templates
friend functions – however, by default everything in a package is a friend of everything else
in the package
multiple inheritance – however, some uses can be replaced by interfaces

2.2 What’s left?

Java’s primitive data types have specified ranges:

boolean (1 bit), char (2 bytes, Unicode),
byte (1 byte), short (2 bytes),
int (4 bytes), long (8 bytes),
float (4 bytes, IEEE 754),
double (8 bytes, IEEE 754)
Java also has arrays, which can be multi-dimensional.

Java contains C’s if, else, for, while, do while and switch statements. However, all conditions must return a boolean. So, some of the more obscure conditions of C are prohibited.

2.3 What’s new? (a) Garbage collection

People sometimes write Pascal/C/C++ code that inadvertently dispose/free/delete objects which are still in use:

var p, q:^integer;
int *p, *q;
new(p);
p = malloc(sizeof(int));
p^ := 27;
*p = 27;
q := p;
q = p;
dispose(p);
free(p);
writeln(q^);
printf(“%d\n”, *q);

In Pascal/C/C++, programs often cause memory leaks by not using dispose/free/delete on objects no longer in use.

In Java, you do not delete objects: instead, Java has garbage collection. The garbage collector detects objects no longer in use, and reuses their space. You also do not have to provide destructors for classes.

2.4 What’s new? (b) Multithreading

In Java, you can easily start more than one thread of execution.

If a variable is accessed by two (or more) methods which are called from different threads, you can ensure that the variable is accessed properly by using synchronized:

public class Store {
private int i; …
public synchronized int get() {
… return i;
}
public synchronized void put(int v) {
i = v; …
}
}

2.5 An example of a class

In Java, it is possible to use a class declaration to define your own type. Suppose that it is necessary to manipulate some dates in a program. Here is a rather primitive class declaration:

public class Date {
public int day, month, year;
public void display() {
System.out.println(day + “-” + month
+ “-” + year);
}
}
public class UseDate {
public static void main(String[ ] args) {
Date noel = new Date();
noel.day = 25;
noel.month = 12;
noel.year = 1996;
noel.display();
}
}

2.6 A better version of the class Date

A private modifier can be used to hide the representation:

public class BetterDate {
private int day, month, year;
BetterDate (int d, int m, int y) {
day = d; month = m; year = y;
}
public void display() {
System.out.println(day + “-” + month
+ “-” + year);
}
}
public class UseBetterDate {
public static void main(String[ ] args) {
BetterDate noel =
new BetterDate(25, 12, 1996);
noel.display();
}
}

If necessary, other methods can be provided to access the hidden fields or to update them.

2.7 An example of inheritance

Inheritance can be used when a class is a more specialized form of another class:

import java.util.Vector;
public class Stack extends Vector {
public Stack() { super(); }
public void push(Object item) {
addElement(item);
}
public Object pop() {
int s = size();
Object item = elementAt(s – 1);
removeElementAt(s – 1);
return item;
}
}
A Java application that uses the Stack class is at the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/UseS tack.java
2.8 Exception handling: (a) throwing

If a method detects that some untoward event has occurred, it can use a throw statement to signify that an exception has occurred:

import java.util.Vector;
public class BetterStack extends Vector {
public BetterStack() { super(); }
public void push(Object item) {
addElement(item);
}
public Object pop()
throws BetterStackException {
int s = size();
if ( s == 0 )
throw new BetterStackException();
Object item = elementAt(s – 1);
removeElementAt(s – 1);
return item;
}
}
public class BetterStackException
extends Exception {
public BetterStackException() {
super();
}
}

If a method throws an exception, this must be documented in the heading of the method by a throws cause.

2.9 Exception handling: (b) catching

In Java, a try statement with one or more exception handlers (each introduced by the keyword catch) is used to indicate that a piece of code wishes to handle exceptions.

If a throw statement is executed, control is transferred to the exception handler of the most-recently-entered try statement containing an appropriate exception handler:

BetterStack s = new BetterStack();
try {
System.out.println(s.pop().toString());
}
catch( BetterStackException e ) {
System.out.println(“empty stack”);
}

A complete Java application that uses the BetterStack class is at the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/UseB etterStack.java
2.10 Package declarations

In Java, a package is a collection of classes. You can indicate that a class belongs to a particular package by a package declaration at the start of the file:

package myutils;

It is possible for Java source code to refer to classes in different packages even if they have the same name. For example, suppose some code requires to use both the class Stack from the package java.util and the class Stack from the package myutils. It can do this using the names java.util.Stack and myutils.Stack.

Java specifies a convention for generating globally unique names, e.g., UK.ac.dur.dcl0bjc.myutils.Stack.

3. Java’s packages

3.1 Packages of the Core API

In order to support programming in Java, many packages have already been constructed. Here is a list of the packages that belong to the Core API of JDK 1.0.2:

java.applet is used to support the writing of applets
java.awt is the Abstract Window Toolkit (AWT) which allows a GUI to be written without regard to the platform(s) on which the program will be executed
java.io is for reading/writing streams, files, pipes
java.lang defines the classes Object, Class, Thread, Boolean, Character, Integer, Float, Double, Math and String
java.net is used to support network programming
java.util includes the classes BitSet, Date, Dictionary, HashTable, Random, Stack and Vector
The packages are documented at:

http://www.javasoft.com/products/JDK/1.0.2/api/

This URL gives the Core API for JDK 1.0.2. However, the Core API of JDK 1.1 has many other APIs.

3.2 Handling strings

In the package java.lang, there are two classes that store and manipulate character data: String is used for immutable strings and StringBuffer is used for mutable strings. Objects of the class String are usually more efficiently handled than StringBuffers, and they can be shared.

String includes the following methods:

length, charAt, toLowerCase, toUpperCase, equals, equalsIgnoreCase, compareTo, startsWith, endsWith, indexOf, lastIndexOf, substring, trim, concat, replace

StringBuffer includes the following methods:

length, capacity, charAt, setCharAt, insert, append, toString

3.3 An example of processing a string

Here is a method (called reverse) that uses the classes String and StringBuffer:

public class StringExtras {
public static String
reverse(String source) {
int charNum;
int numChars = source.length();
StringBuffer temp =
new StringBuffer(numChars);
for (charNum = (numChars-1);
charNum>=0; charNum—) {
temp.append(source.charAt(charNum));
}
return temp.toString();
}

}

3.4 Providing a GUI

The package java.awt consists of many classes forming the Abstract Window Toolkit. It provides GUI components such as: buttons, checkboxes, lists, menus and text areas. It also includes containers (such as windows and menu bars), and higher-level components (such as dialog boxes, including dialog boxes for opening or saving files). There are also classes for basic drawing operations, and for manipulating images, fonts and colours, and for handling events such as mouse clicks.

3.5 An example of providing a GUI

Suppose we want to construct a Java applet that has a button and a textfield such that each time the button is pressed the textfield is updated to show the current date and time.

With JDK 1.0.x, we can override the method handleEvent of the class java.awt.Component:

import java.applet.Applet;
import java.awt.*;
import java.util.Date;
public class ButtonClock extends Applet {
private TextField tTextField =
new TextField(“hello”, 35);
private Button tButton =
new Button(“get date and time”);
public void init() {
add(tButton); add(tTextField);
}
public boolean handleEvent(Event rEvent){
if (rEvent.target.equals(tButton) &&
rEvent.id == Event.ACTION_EVENT) {
Date tDate = new Date();
tTextField.setText(tDate.toString());
return true;
}
return false;
}
}

JDK 1.1 has a better way of handling events. Here is a better version of ButtonClock:

import java.applet.Applet;
import java.awt.*;
import java.util.Date;
import java.awt.event.*;
public class ButtonClock11 extends Applet
implements ActionListener {
private TextField tTextField =
new TextField(“hello”, 35);
private Button tButton =
new Button(“get date and time”);
public void init() {
tButton.addActionListener(this);
add(tButton); add(tTextField);
}
public void actionPerformed
(ActionEvent rActionEvent) {
Date tDate = new Date();
tTextField.setText(tDate.toString());
}
}

For more details about converting programs from using the AWT API of JDK 1.0.x to that of JDK 1.1, see:

http://www.javasoft.com/products/JDK/1.1/docs/guide/awt/HowT oUpgrade.html

3.6 More information about ButtonClock

With an appropriate Java-aware WWW browser, you can execute the above applets from the URLs:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/Butt onClock.html

A more involved example of Java source code that creates a user interface can be displayed by using the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/SAT. java
Because of the way in which it has been written, this source code can be executed either as a Java applet or as a Java application. You can execute the SAT applet through the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/SAT. html

3.7 JDK 1.1

The final release of JDK 1.1 is now available for Windows 95/NT and Solaris (sparc and x86). A version of JDK 1.1 for the Mac is planned for Q2 1997. The next release (JDK 1.1.1) will be a bug-fix release. For more details about JDK 1.1, see:

http://www.javasoft.com/products/JDK/1.1/index.html
The new features of JDK 1.1 include: internationalization, improved security, signed Applets, AWT enhancements, JavaBeans API, networking enhancements, IO enhancements, JAR (Java ARchive), Remote Method Invocation, object serialization, reflection, JDBC (Java DataBase Connectivity), inner classes, a new native method interface, Byte, Short, Void, BigInteger and BigDecimal classes, and performance enhancements. For more details, see:

http://www.javasoft.com/products/JDK/1.1/docs/relnotes/featu res.html
Here are some compatibility issues:

1.0.x bytecode files can be executed by the JDK 1.1 interpreter;
1.0.x Java programs can be compiled by the JDK 1.1 compiler;
1.1 bytecode files are not yet understood by Netscape Navigator.
3.8 Microsoft’s Application Foundation Class

Microsoft has announced its intention to release an API called the Application Foundation Class (AFC). Written in Java and built in terms of the AWT, it will include GUI components such as toolbars, tabbed dialog boxes and tree controls.

Microsoft say that the AFC may be redistributed free by application developers with their products on any Java- capable platform.

The AFC is not currently available for download. Its first beta will be in Q1 1997 and the final release is scheduled for later in the year. This is the same schedule as Internet Explorer 4.0.

For more details about the AFC, see:

http://www.microsoft.com/java/

3.9 Information about other APIs

Besides the Core API, Sun is also defining and publishing Standard Extensions. A broad overview of the current and forthcoming APIs for Java, both for Core libraries and for Standard Extension libraries, can be seen at:

http://www.javasoft.com/products/api-overview.html

4. Other points

4.1 Security issues

Java ensures some problems do not arise: no pointer arithmetic, restricted forms of casting, no indexing outside arrays, no heap and stack overflows. A Java application has unrestricted access to local files, to the network, and to system calls. However, the environment of an applet is controlled by the WWW browser: there is no access to local files in Netscape Navigator, whereas HotJava users can configure read and write access.

Security is a moving target as loopholes get discovered and fixed. For more details, see:

http://www.javasoft.com/sfaq/

For other papers on security, see:

http://www.javasoft.com/security/

The Open Software Foundation has several papers on Java including one entitled Security Features of Java and HotJava:

http://www.osf.org/mall/web/java_rpt.htm

Princeton University’s Department of Computer Science has detected many of Java’s security problems. See the News and Frequently Asked Questions items at: http://www.cs.princeton.edu/sip/

David Hopwood of Oxford University has detected other bugs.

4.2 Other ports of the JDK

HP has ported JDK 1.0.2 to HP-UX 10.01, 10.10 and 10.20 for the HP 9000 systems

HP has also begun a port of the JDK to MPE/iX for the HP 3000 systems.

This WWW page also contains a Java-Linux HOWTO and details about how to execute HotJava, Java Workshop, Jeeves and the JDBC with the Linux port.

IBM has released ports of the JDK for OS/2, OS/390, AIX and Windows 3.1, and work continues on a port to OS/400. The port to Windows 3.1 is called ADK for Win 3.1:

http://www.ibm.com/Java/

The Open Software Foundation has ported JDK 1.0.2 to seven platforms.

4.3 Cloning the JDK

One clone of the JDK is Kaffe from Tim Wilkinson. Kaffe currently interprets bytecodes on Intel, SPARC, the PowerPC, Motorola’s 68K, MIPS and Alpha. Supported OS include SunOS 4.1.x, Solaris 2.x, Irix, Linux, Windows 95 and AmigaOS. On Pentiums and Sparcs, Kaffe also has a just- in-time (JIT) compilation system which translates the bytecode to native machine code on a method-by-method basis as the application is executed. “This has demonstrated speedups of 10 times that of Sun’s JDK, and is general[ly] about half the speed of optimised C code.”

Another clone of the JDK is guavac produced by Effective Edge Technologies. Written in C++, release 0.2.5 “has been tested under Solaris 2.x, SunOS 4.x, Iris 5.3, HP/UX 9, and Linux 1.x using gcc-2.7.2 and libg++-2.7.1 and binutils-2.6, but other operating systems should work without any major changes”. For more details. Andreas Krall has released version 0.1 of CACAO, a 64 bit JIT system for an Alpha running Linux or Digital Unix.

4.4 Tools to support Java

A debugger (jdb) and a documentation tool (javadoc) form part of Sun’s JDK.

Sun’s Java Workshop includes: Project Manager, Visual Java (a GUI builder), Source Editor, Build Manager, Debugger, Source Browser, Project Tester, Portfolio Manager. For more details (including a free 30-day trial offer).

4.5 Integrated Development Environments

Borland C++ 5.0 includes Java development tools such as AppExpert, a visual debugger, a project manager and AppAccelerator (a just-in-time compiler). Borland is producing a complete product called JBuilder (previously called Latte). Borland intend to release a beta which complies with JDK 1.1 in Q1 1997.

Symantec has released Café for Windows 95/NT and the Macintosh. Based in part on the Symantec C++ 7.2 IDDE, it includes a Java compiler, browser, Java-aware editor, class editor, hierarchy editor and debugger. More recently, they have released for the same platforms “a complete Rapid Application Development (RAD) environment for Java” called Visual Café. For Windows 95/NT, there is also a Pro version which provides support for database servers.

Rogue Wave has an IDE called JFactory. It is available for Windows 95/NT, Solaris 2.x (sparc), HP-UX 10.x and OS/2. See:

Metrowerks has support for Java in their development environment CodeWarrior for Windows 95/NT and the Macintosh. See:

Asymetrix has an IDE for Windows 95/NT called SuperCede. They claim to have “the fastest and easiest-to-use” IDE. It is available free for 15 days and then costs $99.95. The compiler can also generate x86 code. See:

Microsoft has a product for Windows 95/NT called Visual J++. Version 1.0 costs $99; claims to compile at over 10,000 lines per second; and includes wizards to help developers reuse existing ActiveX controls and to create new ones. See:

http://www.microsoft.com/visualj/

On March 19th, Microsoft plan to release Visual Studio 97 (previously known as Boston) containing new versions of Visual Basic (5.0), Visual C++ (5.0), Visual J++ (1.1), Visual FoxPro (5.0) and Visual InterDev (1.0). The Java, C++ and InterDev products will all share the common development environment called Developer Studio. See:

http://www.microsoft.com/vstudio/

Marimba has produced Bongo. It costs $495. See:

http://www.marimba.com/products/

Visix Software is developing a product called Vibe. Beta versions are available free for Windows 95/NT, Solaris 2.5, Linux, AIX and Irix.

Sybase has released a second beta of Jato (previously known as Starbuck) with a final release planned for mid-1997. This is a RAD Java development tool that includes JavaBeans and ActiveX component integration. Jato also includes jdbcConnect which offers direct access to databases and a Visual SQL query editor. See: http://www.powersoft.com

IBM are developing a RAD environment for Java called VisualAge for Java with a beta release due out in April and support for Windows 95/NT, OS/2, AIX, AS/400 and MVS.

4.6 Compiling other languages into bytecodes

Intermetrics is producing AppletMagic, an Ada95 compiler that generates bytecodes. There are versions for Windows 95/NT, Windows 3.1 + Win32S, MacOS, SunOS 4.x and Solaris 2.x.

ObjectAda for Windows (a GUI Builder) produces bytecodes and is available for Windows 95/NT and Windows 3.1 + Win32S.

GNAT (the Ada95 compiler from New York University) may be re-targetted to generate bytecodes. S

NetRexx is derived from an earlier language called Rexx. It is claimed that by using NetRexx you can create programs and applets for the Java environment faster and more easily than by programming in Java. NetRexx source code is currently translated into Java source code. The NetRexx compiler executes on any Java platform.

4.7 Books on Java

Although the book Teach Yourself Java in 21 Days by Laura Lemay and Charles L. Perkins has had numerous errors, it is quite a good book for getting started with Java.

Java in a Nutshell: A Desktop Quick Reference for Java Programmers by David Flanagan (from O’Reilly and Associates) is excellent for those who know C++ (or possibly just C). Costing just £14.95 or $19.95, it includes useful summaries of various aspects of the language and the packages. Its ISBN is 1-56592-183-6. They are releasing a second edition for JDK 1.1 as soon as possible.

SunSoft Press has published some books on Java.

Addison-Wesley has published several books in their Java series. The most important ones are The Java Language Specification (ISBN 0-201-63451-1) and The Java Class Libraries: An Annotated Reference Specification (ISBN 0- 201-63458-9): The texts of some of these books are available through the WWW at the URLs given later and some form part of Microsoft’s Visual J++ product.

4.8 Primary resources on Java

The most important URL for information about Java is:

http://www.javasoft.com
In particular, Sun’s Java documentation is at:

The programming languages subcommittee of ISO has formed a Java Study Group.

4.10 Not just a programming language

Sun Microelectronics is producing a chip that can process Java bytecodes: picoJAVA. It will be suitable for cellular phones, printers and other consumer and peripheral markets. The microJAVA and ultraJAVA chips will be more advanced, e.g., handling graphics and multi- media.

Sun has produced JavaOS which provides a standalone Java environment, i.e., a processor does not need an operating system (other than JavaOS) in order to execute Java applications. It is currently available for sparc, x86 and ARM processors.

Sun has produced a network computer called a JavaStation. This is a disc-less machine that understands Java. So, it has no disc drives, no floppy, no CD-ROM, no slots and no jumpers.

The way in which Java is being deployed by companies such as BT is given at:

http://www.sun.com/javastation/customersuccesses/

5. Conclusions

  • It is nice to have a programming language that supports object-oriented programming, exception handling and concurrency.
  • Also, it is easy to build GUIs.
  • Many of the problems with the C++ language are avoided.
  • Programs are instantly portable across platforms.
  • The text of this paper is updated from time to time.

JAVA For Network Label Printing

Topic or Information

Java example for printing via a network connection

Applies To

Java programming for Zebra Thermal Label Printers

Details

The following is a simple example that illustrates how one is able to use Java to print via a network connection.

import java.io.*;
import java.net.*;
class TCPClient
{
public static void main (String argv[]) throws Exception
{
// The line below illustrates the default port 6101 for mobile printers 9100 is the default port number
// for desktop and tabletop printers
Socket clientSocket=new Socket(“10.17.50.105”,6101);

DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream() );
//The data being sent in the lines below illustrate CPCL one can change the data for the corresponding
//language being used (ZPL, EPL)

outToServer.writeBytes(“! 0 200 200 203 1” + ‘n’ + “CENTER” + ‘n’);
outToServer.writeBytes(“TEXT 0 3 10 50 JAVA TEST” + ‘n’ + “PRINT” + ‘n’);

clientSocket.close();
}
}

How to Print Labels from Word to a Zebra Printer

Zebra manufactures thermal printers that allow businesses to print high-quality receipts, labels and other documentation using common word processing programs, such as Microsoft Word. These printers also have the capability to print scannable barcodes on labels for shipping, inventory pricing or identification purposes. The printer utilizes Zebra programming language, or ZPL, to create barcodes. However, all models have the barcode commands already installed on their internal memory, so you do not need any additional barcode fonts when you use Word to print these types of labels.

Step 1

Open a new Microsoft Word document.

Step 2

Click the “Mailings” tab on the menu bar at the top of the window. Click the “Labels” option in the “Create” section.

Step 3

Enter the information you want to include on the label in the “Address” text box.

Step 4

Click the “Options” button to bring up the advanced settings dialog box.

Step 5

Click the “Continuous-feed printers” bubble. Select “Zebra” from the “Label vendors” drop-down box. Choose the product number from the list. Click “OK” to return to the main “Labels” menu.

Step 6

Click the “New Document” button. The label will appear on the screen.

Step 7

Enter a barcode on the label by placing the cursor in the top-left corner of the label. Type “~C2B” followed a space and the command for the barcode you want to insert. Refer to the programming guide for your Zebra printer model for the barcode commands.

Step 8

Click the “File” tab and select the “Print” option. Under the “Printer” option, select “Zebra.” Click the “Print” button to send the label to the Zebra printer.

 

Label Supplies For Printing

 

You can buy blank sheets of labels and thermal labels on rolls in the UK from Cloud Labels. They offer free delivery to the UK Mainland and also have a wide range of label templates that you can download on their website.

**Update** – Cloud labels now also supply eco-friendly biodegradable labels on A4 sheets that are kinder to the environment than standard labels. They are made from cane fibre and we would highly recommend them. You can’t use these labels through a Zebra thermal printer, but they can be used with both laser and inkjet printers.

If you need any more help then please contact us with your questions.