Tuesday, April 25, 2006

Java definition

An object-oriented programming language that is platform independent (the same Java program runs on all hardware platforms without modification). Developed by Sun, Java is widely used on the Web for both client and server processing. Modeled after C++, Java added programming enhancements such as "garbage collection," which automatically frees unused memory. It was also designed to run in small amounts of memory. The first Web browsers to run Java were Sun's HotJava and Netscape Navigator 2.0.Applets, Applications and ServletsJava programs can be called from Web pages or run stand alone. When launched from a Web page, the program is called a Java "applet." When a non Web-based Java program is run on a user's machine, it is a Java "application." When running in a Web server, it is a Java "servlet."Intermediate BytecodeThe source code of a Java program is compiled into an intermediate language called "bytecode," which can reside on any hardware platform. In order to run the bytecode, it must be compiled into machine code either ahead of time like a C/C++ program, just before it is needed (see JIT compiler) or via a Java Virtual Machine (JVM), which is a line-at-a-time interpreter. There are compilers and JVMs for all major hardware platforms, and the intermediate bytecode is what makes Java machine independent.Java Vs. JavaScriptJava is a full-blown programming language, whereas JavaScript is a scripting language that is much more limited in scope. 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, JavaScript is widely used to provide drop-down menus and other interactive events on the page. See JavaScript.
A Revolution?Java was originally developed in 1991 as a language for embedded applications such as those used in set-top boxes and other consumer-oriented devices. It became the fuel to ignite a revolution in thinking when Sun transitioned it to the Web in 1994. Java is a full-blown programming language like C and C++ and allows for the creation of sophisticated applications. Thus far, Java applications and applets have been mildly successful at the client side, but Java on the server has become very popular. Sun's J2EE enterprise model has become an application server standard (see J2EE).Write Once-Run AnywhereJava embodies the "write once-run anywhere" model, which has been one of the Holy Grails of computing for decades. For example, a J2EE server application can be replicated from a Unix server to a Windows server and vice versa with relative ease. Sometimes, a little tweaking is necessary; sometimes a lot, but Java is closer to "write once-run anywhere" than any development platform in the past. 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);
}
}
Java Uses an Intermediate Language
Java source code is compiled into an intermediate language called "bytecode." The bytecode can be run in any hardware that has a Java Virtual Machine (JVM) for that machine platform. Thus, the "write once-run anywhere" concept.
Java Runs on Clients and Servers
When a Java program has been called by a Web page from the client machine, it is dubbed an "applet." When it runs on the server, it is known as a "servlet." When running stand alone in a user's computer, it is a Java "application."
Sources=Sources 32
Attribution()

0 Comments:

Post a Comment

<< Home