Header Ads Widget

Responsive Advertisement

History of Java Programming Language Free Java Guide & Tutorials


“History of Java Programming Language” Free Java Guide & Tutorials


Java is an item-orientated programming language evolved via way of means of James Gosling and colleagues at Sun Microsystems withinside the early 1990s. Unlike traditional languages which can be commonly designed both to be compiled to local (gadget) code, or to bet Interpretedrom supply code at runtime, Java is supposed to be compiled to a bytecode, that's then run (commonly the usage of JIT compilation) via way of means of a Java Virtual Machine.The language itself borrows lots syntax from C and C++ however has a easier item version and less low-stage facilities. Java is best distantly associated with JavaScript, though they have got comparable names and proportion a C-like syntax.




History


Java became commenced as a challenge known as "Oak" via way of means of James Gosling in June 1991. Gosling's dreams had been to enforce a digital gadget and a language that had a acquainted C-liken notation however with more uniformity and ease than C/C++. The first publicp Implementation ecame Java 1.zero in 1995. It made the promise of "Write Once, Runn Anywhere with unfastened runtimes on famous systems. It became pretty stable and its security became onfigurable, making an allowance for community and report get entry to to be limited. The fundamental webr browser suickly included it into their fashionable configurations in a stable "applet" Configuration famous quickly. New variations for big and small systems (J2EE and J2ME quickly had been designed with the arrival of "Java 2". Sun has now no longer introduced any plansor a "Java 3".


In 1997, Sun approached the ISO/IEC JTC1 requirements frame and later the Ecman Internationalo formalize Java, however it quickly withdrew from the process. Java stays a proprietarye facto fashionable this is managed via the Java Community Process. Sun akes maximum of its Java implementations to be had with out charge, with revenue being enerated via way of means of specialised merchandise inclusive of the Java Enterprise System. Sun distinguishesamong its Software Development Kit (SDK) and Runtime Environment (JRE) that's a subset of the SDK, the number one difference being that withinside the JRE the compilersn't always present.



Philosophy


There had been 5 number one dreams withinside the introduction of the Java language:

1. It must use the item-orientated programming technique.

2. It must permit the identical application to be achieved on more than one working structures.

3. It must include integrated aid for the usage of pc networks.

4. It must be designed to execute code from faraway reassets securely.

5. It must be clean to apply via way of means of deciding on what became taken into consideration the best components of different item-orientated languages.

To obtain the dreams of networking aid and faraway code execution, Java Programmersvery now and then discover it important to apply extensions inclusive of CORBA, Internet Communicationsngine, or OSGi.



Object orientation


The first characteristic, item orientation ("OO"), refers to a technique of programming and language layout. Although there are numerous interpretations of OO, one number one distinguishing concept is to layout software program in order that the numerous sorts of facts it manipulates are mixed collectively with their applicable operations. Thus, facts and code are mixed into entities known as gadgets. An item may be notion of as a self-contained package deal of conduct (code) and state (facts). The precept is to split the matters that extrade from the matters that live the identical; regularly, a extrade to a few facts structure calls for a corresponding extrade to the code that operates on that facts, or vice versa. This separation into coherent gadgets affords a greater strong basis for a software program system's layout. The reason is to make big software program tasks simpler to manage, for this reason enhancing high-satisfactory and decreasing the quantity of failed tasks. Another number one purpose of OO programming is to expand greater regular gadgets in order that software program can emerge as greater reusable among tasks. A regular "customer" item, for example, must have more or less the identical fundamental set of behaviors among specific software program tasks, particularly while those tasks overlap on a few essential stage asthey regularly do in big organizations. In this sense, software program gadgets can optimistically be visible greater as pluggable components, assisting the software program enterprise construct tasks in large part from current and well-examined pieces, for this reason main to a huge discount in improvement times. Software reusability has met with combined sensible outcomes, with two predominant difficulties: the layout of really regular gadgets is poorly understood, and a technique for large verbal exchange of reuse possibilities is lacking. Some open supply groups need to assist ease the reuse hassle, via way of means of imparting authors with approaches to disseminate records approximately commonly reusable gadgets and item libraries.



Platform independence


The 2d characteristic, platform independence, approach that applications written withinside the Java language should run in addition on numerous hardware. One must be capable of write a application as soon as and run it anywhere.


This is accomplished via way of means of maximum Java compilers via way of means of compiling the Java language code"halfway" to bytecode (in particular Java bytecode)—simplified gadget commands particular to the Java platform. The code is then run on a digital gadget (VM), a application written in local code at the host hardware that translates and executes regular Java bytecode. Further, standardized libraries are supplied to permit get entry to to functions of the host machines (inclusive of graphics, threading and networking) in unified approaches. Note that, even though there is an specific compiling stage, at a few factor, the Java bytecode is interpreted or transformed to local gadget commands via way of means of the JIT compiler.


There also are implementations of Java compilers that bring together to local item code, inclusive of GCJ, eliminating the intermediate bytecode stage, however the output of those compilers can best be run on a unmarried architecture.


Sun's license for Java insists that every one implementations be "compatible". This led to a felony dispute with Microsoft after Sun claimed that the Microsoft implementation did now no longer aid the RMI and JNI interfaces and had brought platform-particular functions of their own. In response, Microsoft not ships Java with Windows, and in latest variations of Windows, Internet Explorer can not aid Java applets with out a third-celebration plug-in. However, Sun and others have made to be had Java run-time structures for gratis for the ones and different variations of Windows.


The first implementations of the language used an interpreted digital gadget to obtain portability. These implementations produced applications that ran greater slowly than applications compiled to local executables, for example written in C or C++, so the language suffered a popularity for terrible overall performance. More latest JVM implementations produce applications that run notably quicker than before, the usage of more than one techniques. The first method is to truely bring together without delay into local code like a greater traditional compiler, skipping bytecodes entirely. This achieves right overall performance, however on the fee of portability. Another method, referred to as just-in-time compilation (JIT), interprets the Java bytecodes into local code on the time that this system is administered which outcomes in a application that executes quicker than interpreted code however additionally incurs compilation overhead throughout execution. More state-of-the-art VMs use dynamic recompilation, wherein the VM can examine the conduct of the going for walks application and selectively recompile and optimize important components of this system. Dynamic recompilation can obtain optimizations advanced to static compilation due to the fact the dynamic compiler can base optimizations on know-how approximately the runtime surroundings and the set of loaded lessons. JIT compilation and dynamic recompilation permit Java applications to take gain of the rate of local code with out dropping portability.


Portability is a technically tough purpose to obtain, and Java's achievement at that purpose has been combined. Although it's miles certainly feasible to jot down applications for the Java platform that behave always throughout many host systems, the big quantity of to be had systems with small mistakes or inconsistencies led a few to parody Sun's "Write as soon as, run anywhere" slogan as "Write as soon as, debug everywhere". Platform-impartial Java is but very a success with server-aspect applications, inclusive of Web services, servlets, and Enterprise JavaBeans, in addition to with Embedded structures primarily based totally on OSGi, the usage of Embedded Java environments.



Automatic garbage collection


One concept at the back of Java's computerized reminiscence control version is that programmers must be spared the load of getting to carry out guide reminiscence control. Insome languages the programmer allocates reminiscence to create any item saved at the heap and is answerable for later manually deallocating that reminiscence to delete any such gadgets. If a programmer forgets to deallocate reminiscence or writes code that fails to do so in a well timed fashion, a reminiscence leak can arise: this system will devour a potentially arbitrarily big quantity of reminiscence. In addition, if a vicinity of reminiscence is deallocated twice, this system can emerge as volatile and might crash. Finally, in non rubbish accrued environments, there may be a sure diploma of overhead and complexity of user- code to tune and finalize allocations. In Java, this capability hassle is prevented via way of means of computerized rubbish series. The programmer determines while gadgets are created, and the Java runtime is responsible for coping with the item's lifecycle. The application or different gadgets can reference an item via way of means of protecting a connection with it (which, from a low-stage factor of view, is its address at the heap). When no references to an item remain, the Java rubbish collector routinely deletes the unreachable item, liberating reminiscence and stopping a reminiscence leak. Memory leaks may also nonetheless arise if a programmer's code holds a connection with an item this is not needed—in different words, they are able to nonetheless arise however at higher conceptual levels.


The use of rubbish series in a language also can have an effect on programming paradigms. If, for example, the developer assumes that the fee of reminiscence allocation/recollection is low, they will pick to greater freely assemble gadgets rather than pre-initializing, protecting and reusing them. With the small fee of capability overall performance penalties (inner-loop production of big/complicated gadgets), this enables thread-isolation (no want to synchronize as specific threads paintings on specific item instances) and facts-hiding. The use of temporary immutable value-gadgets minimizes aspect-impact programming. Comparing Java and C++, it's miles feasible in C++ to enforce comparable functionality (for example, a reminiscence control version for particular lessons may be designed in C++ to enhance velocity and decrease reminiscence fragmentation considerably), with the feasible fee of more improvement time and a few utility complexity. In Java, rubbish series is integrated and truely invisible to the developer. That is, builders may also don't have any belief of while rubbish series will take location as it is able to now no longer always correlate with any moves being explicitly achieved via way of means of the code they write. Depending on supposed utility, this will be useful or disadvantageous: the programmer is freed from appearing low-stage tasks, however on the identical time loses the choice of writing decrease stage code.




Syntax


The syntax of Java is basically derived from C++. However, in contrast to C++, which combines the syntax for structured, regular, and item-orientated programming, Java became constructed from the floor as much as be truely absolutely item-orientated: the entirety in Java is an item with the exceptions of atomic datatypes (ordinal and actual numbers, boolean values, and characters) and the e



Applet


Java applets are programs that are embedded in other applications, typically in a Web

page displayed in a Web browser.

// Hello.java

import java.applet.Applet;

import java.awt.Graphics;

public class Hello extends Applet {

public void paint(Graphics gc) {

gc.drawString("Hello, world!", 65, 95);

}

}

This applet will simply draw the string "Hello, world!" in the rectangle within which the

applet will run. This is a slightly better example of using Java's OO features in that the

class explicitly extends the basic "Applet" class, that it overrides the "paint" method and

that it uses import statements.

<!-- Hello.html -->

<html>

<head>

<title>Hello World Applet</title>

</head> <body>

<applet code="Hello" width="200" height="200">

</applet>

</body>

</html>

An applet is placed in an HTML document using the <applet> HTML element. The

applet tag has three attributes set: code="Hello" specifies the name of the Applet class

and width="200" height="200" sets the pixel width and height of the applet. (Applets

may also be embedded in HTML using either the object or embed element, although

support for these elements by Web browsers is inconsistent.


Servlet

Java servlets are server-side Java EE components that generate responses to requests

from clients.

// Hello.java

import java.io.*;

import javax.servlet.*;

public class Hello extends Generic Servlet {

public void service(Servlet Request request, Servlet Response response)

throws Servlet Exception, IOE xception

{

response.setContentType("text/html");

Print Writer pw = response.getWriter();

pw.println("Hello, world!");

pw.close();

}

}

The import statements direct the Java compiler to include all of the public classes and

interfaces from the java.io and javax.servlet packages in the compilation. The Hello

class extends the GenericServlet class; the GenericServlet class provides the interface

for the server to forward requests to the servlet and control the servlet's lifecycle.

The Hello class overrides the service(ServletRequest, ServletResponse) method

defined by the Servlet interface to provide the code for the service request handler. The

service() method is passed a ServletRequest object that contains the request from the

client and a ServletResponse object used to create the response returned to the client.

The service() method declares that it throws the exceptions ServletException and

IOException if a problem prevents it from responding to the request.

The setContentType(String) method in the response object is called to set the MIME

content type of the returned data to "text/html". The getWriter() method in the response

returns a PrintWriter object that is used to write the data that is sent to the client. The

println(String) method is called to write the "Hello, world!" string to the response and

then the close() method is called to close the print writer, which causes the data that

has been written to the stream to be returned to the client.


Swing application

Swing is the advanced graphical user interface library for the Java SE platform.

// Hello.java

import javax.swing.*;

public class Hello extends JFrame {

Hello() {

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

add(new JLabel("Hello, world!"));

pack();

}

public static void main(String[] args) {

new Hello().setVisible(true); 

}

The import statement directs the Java compiler to include all of the public classes and 

interfaces from the javax.swing package in the compilation. The Hello class extends the 

JFrame class; the JFrame class implements a window with a title bar with a close 

control. 


The Hello() constructor initializes the body through first calling the setDefaultCloseOperation(int) technique inherited from JFrame to set the default operation whilst the near manage at the name bar is chosen to WindowConstants.DISPOSE_ON_CLOSE—this reasons the JFrame to be disposed of whilst the body is closed (in place of simply hidden), which lets in the JVM to exit and this system to terminate. Next a brand new JLabel is created for the string "Hello, world!" and the upload(Component) technique inherited from the Container superclass is known as to upload the label to the body. The pack() technique inherited from the Window superclass is known as to length the window and format its contents. 


The main() technique is known as through the JVM whilst this system starts. It instantiates a brand new Hello body and reasons it to be displayed through calling the setVisible(boolean) technique inherited from the Component superclass with the boolean parameter true. Note that as soon as the body is displayed, exiting the primary technique does now no longer reason this system to terminate due to the fact the AWT occasion dispatching thread stays lively till all of the Swing top-degree home windows had been disposed. 



Look and feel


The default appearance and experience of GUI programs written in Java the usage of the Swing toolkit is Very exceptional from local programs. It is feasible to specify a exceptional appearance and experience thru the pluggable appearance and experience gadget of Swing. Clones of Windows, GTK and Motif are provided through Sun. Apple additionally gives an Aqua appearance and experience for Mac OS X.Though previous implementations of those appearance and feels had been taken into consideration lacking, Swing in Java SE 6 addresses this hassle through the usage of extra local widget drawing workouts of the underlying platforms. Alternatively, 1/3 celebration toolkits inclusive of wx4j or SWT can be used for accelerated integration with the local windowing gadget.



Lack of OO purity and facilities 


Java's primitive kinds aren't objects. Primitive kinds maintain their values withinside the stack in preference to being references to values. This turned into a aware choice through Java's designers for overall performance reasons. Because of this, Java isn't taken into consideration to be a natural object-orientated programming language. However, as of Java 5.0, autoboxing permits programmers to put in writing as though primitive kinds are their wrapper classes, and freely interchange among them for progressed flexibility. Java designers determined now no longer to put in force sure functions found in different OO languages, including:


  1. a couple of inheritance
  2. operator overloading
  3. elegance properties
  4. tuples



Java Runtime Environment


The Java Runtime Environment or JRE is the software program required to run any application deployed at the Java Platform. End-customers usually use a JRE in software program packages and Web browser plugins. Sun additionally distributes a superset of the JRE known as the Java 2 SDK (extra usually called the JDK), which incorporates improvement gear inclusive of the Java compiler, Javadoc, and debugger.


Post a Comment

0 Comments