Java
An object-oriented programming language that is platform independent. Developed by Sun, Java is widely used on the Web for both client and server processing. Modeled after C++ and designed to run in limited memory, Java added programming enhancements such as "garbage collection," which automatically frees unused memory.
Intermediate Bytecode
The source code of a Java program is compiled into an intermediate language called "bytecode." In order to run the bytecode, it must be compiled into machine code just before execution or a line at a time via the Java Virtual Machine (JVM) runtime engine. There are JVMs for all major hardware platforms, and this intermediate bytecode is what makes Java cross platform. See Java Virtual Machine and JIT compiler.
Java Vs. JavaScript
Java is a full-blown programming language, whereas JavaScript is a scripting language that is much more limited. JavaScript source code is not compiled into bytecode. It is embedded within an HTML page and is primarily used to manipulate elements on the page itself. For example, it is widely used to provide drop-down menus and other interactive events on the page. See JavaScript.
A Revolution?
Developed in 1991 as a language for embedded applications in set-top boxes and other consumer electronics, Java ignited a revolution when Sun transitioned it to the Web in 1994. Thus far, Java applets and applications have been mildly successful on the client, but Java on the server side has become very popular. See J2EE.
Write Once-Run Anywhere
Java embodies the "write once-run anywhere" model; the Holy Grail of computing for decades. For example, a Java servlet can be moved from a Unix server to a Windows server if both have the Java runtime engine installed. Sometimes, a little tweaking is necessary; sometimes a lot, but Java is closer to "write once-run anywhere" than previous development platforms. See Java platform, servlet, JSP, Java 2, Jini, network computer, CaffeineMark and caffeine based.
The following Java example of changing Fahrenheit to Celsius is rather wordy compared to the C example in this encyclopedia. Java is designed for GUI-based applications, and several extra lines of code are necessary here to allow input from a terminal.
import java.io.*;
class Convert {
public static void main(String[]args)
throws IOException {
float fahr;
StreamTokenizer in=new StreamTokenizer(new
InputStreamReader(System.in));
System.out.print("Enter Fahrenheit ");
in.nextToken();
fahr = (float) in.nval;
System.out.println ("Celsius is " +
(fahr-32)*5/9);
}
}
Computer Desktop Encyclopedia THIS DEFINITION IS FOR PERSONAL USE ONLY
All other reproduction is strictly prohibited without permission from the publisher.
Copyright © 1981-2009 by Computer Language Company Inc. All rights reserved.
Share on Facebook