RSS
Translated by

Java

Product
Developers: Oracle
Last Release Date: 2014/03/18
Technology: Development tools of applications

Content

Java is the object-oriented programming language developed by SUN Microsystems company and officially released on May 23, 1995. Sometimes in Russian mispronounce the name as Java, by analogy with the name of Java Island.

Java — so call not only language, but also the platform for creating applications of level of the enterprises on the basis of this language.

Main features of language

Initially modern language of programming was called Oak (in translation from engl. - "Dub") and was developed by James Gosling for consumer electronics, but afterwards was renamed into Java and began to be used for writing of client applications and the server software. It is called in honor of the brand of the Java coffee (Java) loved by programmers therefore on an official emblem of the Java language the cup with the smoking coffee is represented.

Programs on Java are broadcast in the bytecode executed virtual by Java machine (JVM) — the program processing the byte code and telling instructions to the equipment as the interpreter, but with that difference that the byte code, unlike the text, is processed much quicker.

The advantage of a similar method of accomplishment of programs — in complete independence of a bytecode of OS and the equipment that allows to execute Java applications on any device which supports the virtual machine. Other important feature of Java technology is the flexible security system thanks to the fact that execution of the program is completely controlled by the virtual machine. Any transactions which exceed the set program authority (for example, attempt of unauthorized access to data or connections with other computer) cause immediate interruption. It allows users to load the programs written on Java, on their computers (or other devices, for example, mobile phones) from unknown sources, at the same time without being afraid of infection with viruses, losses of valuable information, etc.

Often carry to shortcomings of the concept of the virtual machine that execution of a bytecode the virtual machine can reduce performance of the programs and algorithms implemented in the Java language. This statement was fair for the first versions of the Java virtual machine, however recently it practically lost relevance. It was promoted by a number of improvements: use of JIT technology (Just-In-Time compilation) allowing to transfer a bytecode to machine code during execution of the program with a possibility of preserving of versions of a class in machine code, wide use of the native-code in standard libraries and also the hardware providing the accelerated processing of a bytecode (for example, the Jazelle technology maintained by some processors of ARM company).

The ideas put in the concept and different implementations of JVM inspired a great number of enthusiasts on expansion of the list of languages which could be used for creation of the programs performed in the environment of JVM[1]. This idea has something in common with the concept of CLI, put in a basis .NET platform of Microsoft company.

Control of development and rights to Java

2019

Oracle: we were left without the market of smartphones because of theft of Java technologies for Android

At the end of March, 2019 Oracle asked the Supreme Court USA not to allow the appeal on earlier passed judgement according to which Google violated copyright of Oracle when using components from Java of century to the operating system Android.

According to lawyers of Oracle, the company actually was left without the growing market of smartphones and faced an irreparable negative impact on the business because of illegal operations of Google.

Oracle considers that copyright violation by Google company did not allow Oracle to enter the market of smartphones

Oracle claims that Google destroyed her  hopes to enter  the market of smartphones  as the developer with  the Java platform which gives the chance of development of start of the programs written in  the Java language  including via API interfaces. In  the claim it is specified that Google copied these API without proper license.

«
The theory of Google is that, having enclosed all these resources in creation of the program popular among developers of platforms and applications, Oracle should be obliged to give to the competitor the chance to copy the code to help fans to create own best-sellers — said in Oracle.
»

Google repeatedly stated that if to permit the companies to own copyright of  program interfaces, then  it influence will make negative impact. However Oracle stated to court that software development  "  was not influenced by destructive effects which were predicted by Google; the industry feels better, than ever".

Oracle reminds that licenses for Java are free for developers, but the companies implementing this technology to the platforms should pay.

Google refused to sign the licensing agreement with Oracle as it did not want that the Android-application could work at other platforms. As a result of this Oracle had no opportunity for the competition in the market of smartphones, transfers the CRN edition.[2]

Google: the victory of Oracle in a dispute on use of Java in Android will kill software development

At the end of January, 2019 Google took the Supreme Court USA with the statement to review 9 years' trial with Oracle concerning legality of use of program interfaces  (API) Java  of century to the operating system Android. Google considers that the victory of Oracle will kill software development.

Google asks the highest judicial authority of the USA to join in under two earlier repealed judgments. In one of them the Internet giant said that API are not protected by copyright, and in the friend — Google "legally" uses the program interfaces Java.

Google is not given in a dispute with Oracle on use of Java in Android

In the blog the general counsel of Google Kent Walker compares the API interfaces protected by copyright to "a statement that the hot keys can work only with one type of the computer".

«
We created Android according to long ago the practice of reuse of program interfaces accepted in the computer industry which provide the command sets facilitating implementation of the general functions. It is similar to the hot keys on the computer keyboard when you click Ctrl + P for fast printing — Walker writes.
»

According to him, Android created the reformative new platform, having allowed millions of Java programmers to use the skills which are available for them for development of new applications. Founders of Java supported release of Android, having told that this step will provide a power pulse to community Java, the representative of Google added.

The company considers that the final decision of court which is taken out at the end of March, 2018 in which Google was found guilty of illegal use   of Java API  in  the Android platform became accident for developers.

«
If the Supreme Court does not cancel these two solutions, this case will put an end to traditional capability of developers freely to use the existing program interfaces for creation of new generations of computer programs for consumers — Kent Walker said.[3]
»

2018: A victory over Google in court on the case of Java

On March 27, 2018 the Court of Appeal of the USA on  the federal district made the positive decision for Oracle on trial in which the company accused Google of illegal use of Java API in the Android platform. Read more here. 

2012: Oracle purchased the Java developer

Oracle received control over Java during purchase of SUN Microsystems.

On January 25, 2012 Oracle submitted to JCP the offer according to which some reduction of number of members of executive committee is supposed.

"It is represented that waiting for convergence of Java ME and Java SE the current separation into two separate executive committees does not make sense. As Java is one platform, it also should be under control of one executive committee", said in the text of the recommendation.

It is the second offer of Oracle.

According to entries of 2011 in the blog by the chairman of JCP Patrick Curran, the first and already accepted was aimed at increase in transparency of processes of the specification.

The third which should be just provided will concern the "more complex changes" including possible changes in the contribution agreement in development of the Java specification (Java Specification Participation Agreement), the legal agreement according to which JCP works.

2010: The father of Java demands "freedom from Oracle" for the child

The creator of the Java language James Gosling who left Sun Microsystems after absorption by its Oracle corporation conducts a promotional campaign under the motto "Freedom of Java!". Gosling sets as the purpose to achieve from the head of Oracle Larry Ellison of conversion of the Java Community Process organization in independent, not subject to influence of separate companies. Ellison suggested to create such independent consolidation in 2007.

In the run-up to the JavaOne and Oracle OpenWorld 2010 conferences Gosling released a series of propaganda materials in support of the fight: t-shirts, icons, mugs with texts "Release Java!", "Oracle, keep a promise!" and also with the Ellison's portrait and the signature "Outside for a long time not the 1984th!". The creator of Java urges to come in his t-shirts to the mentioned conferences to show the unindifference to the fate of the platform.

2010: Oracle begins court with Google on the subject Java

In October, 2010 the company Oracle specified the wording of the claim against Google concerning patent infringement and copyright of the Java technologies implemented in mobile to the operating system Android. The first version of the claim taken to court in August, 2010 contained few technical details, but now the company applies to the claim even excerpts from source texts of programs.

Oracle claims that about a third of packets in the program interface (API) Android are derivative of Java packets, copyright of which belongs to Oracle. It concerns, in addition, names of classes and methods, parameters, determinations and the general organization of the code and documentation. A part of the source code was directly taken from the texts of programs of Oracle protected by copyright. The licenses to use Java in itself are free, but in the Android system instead of the Java virtual machine the machine Dalvik of own development of Google, programs for which, however, are written in the Java language, is used. Google considers that claims of Oracle to it and to community of program writers with the open code in general are unreasonable.

2011: Elections to Java Community Process committee

Since November 3, 2011 VMware is not a member of executive [4] any more, but the Twitter company was its part, according to results of elections.

The structure of executive committee on control over development of future versions of specifications of platforms of the Java language, in particular for desktop computers and servers, included Azul Systems company, producer virtual Java machine Zing. Ericsson, Intel and SAP are repeatedly elected as a member of committee. Besides, IBM, Nokia and SK Telecom reserved seats in committee on mobile technologies (Java ME), ARM Limited and Werner Keil received places of open membership.

Despite secession of executive committee, VMware remains the important investor in development of platforms of Java by means of participation of the division of SpringSource which implements a wide range of products for development and deployment of Java applications.

According to the message in the official blog of Oracle company, nearly a quarter (about 23%) of competent members voted on elections.

"It it is much bigger, than 11% which participated in early elections of executive committee in 2011, but it is less, than it was expected", the statement says.

Oracle has permanent membership in committee, but according to regulating documents of community, has no possibility of domination in JCP. In the document it is said, in particular, that Oracle and other members of executive committee exercise functions of groups of technology supervision of work of task forces. "Executive committees do not exercise daily direct manipulation of work of task forces. Executive committees have a possibility of control of work of each group of experts, in accurately designated intervals as specifications pass through JCP", said in the document.

Nevertheless, Oracle aggressively protects the share in Java. Legal procedure against Google for expected violations of intellectual property regarding application of Java in mobile Android OS serves as the evidence of what. There are suspicions that in last Oracle tried to have an unofficial impact on elections of members of JCP.

The community JCP lost such authoritative participant as Apache Software Foundation which refused membership in connection with those signs which it characterized as excessive control of Oracle over Java.

[4] Java Community Process (JCP) is the official community organized in 1998 for participation of the interested companies in formation of specifications of platforms of the Java language.

SE/EE is engaged in platforms for desktop computers (Java Platform, Standard Edition) and for servers (Java Platform, Enterprise Edition)

2012: Victory of Google

In May, 2012 the Federal court of California did not see violations from Google and did not recognize the intellectual property of Oracle programming interfaces and source code lines of Java. Oracle submitted the appeal.

2014: The Supreme Court considers a dispute of Oracle and Google

In May, 2014 the Federal Court of Appeal of the USA cancelled the decision made for benefit of Google. Behind the appeal of this resolution Google addressed to the U.S. Supreme Court.[5]

At the beginning of December, 2014 Oracle sent the appeal in which it asked to uphold the decision of Court of Appeal to the U.S. Supreme Court. At the same time American representative of Themis received the document in which eminent persons of computer sciences support Google.

"Leave unprotected thousands of lines of the code copied by Google would mean deprivation of copyright protection concerning all code", said in the statement of Oracle.

Google parries it the fact that it had no choice except how to use the ready Java components for development of Android OS as Java was already strongly widespread, and programmers needed familiar program interfaces for writing of Java software. Such functional code does not get under protection of the American legislation on copyright, claim in Google.

The patent lawsuit of Oracle and Google will affect the software market

Google supported a number of prominent specialists in computer sciences. One of founders of the Internet Vinton Cerf, operating system Unix the developer Ken Thompson and some more dozens of famous veterans of the PC industry sent to the Supreme Court the letter in which they asked to review the decision of Court of Appeal and to recognize that program interfaces are not subject of copyright.

According to authors of the address, the situation at which programmers, creating the program interfaces for applications, will worry about acquisition of the license for API will strongly slow down development of innovations and will create a serious barrier on the way of establishing compatibility of software products.

The possibility of free use of third-party API promotes creation of the software which developers of original programming interfaces would never guess or could not create due to the lack of necessary resources, specialists say.

The verdict of the Supreme Court can be defining for development of all software industry. If the solutions API are recognized intellectual property, then the compatibility and portability of products as questionable there will be a legality of creation of functional analogs of software platforms by development of own compatible API will suffer.

Classification of platforms of Java

In Java there are three main families of technologies:

  • J2EE or Java EE (since v1.5) — Java Enterprise Editon, for creation of the software of the enterprise level;
  • J2SE or Java SE (since v1.5) — Java Standard Editon, for creation of user applications, first of all — for the desktop systems;
  • J2ME, Java ME or Java Micro Edition, for use in the devices limited on computing power including mobile phones, PDA, the built-in systems

Server technologies of the J2EE family are considered as the most popular.

The last release is version 1.6 in which improvement of a security system, support improvement was made XML and also support scripting language JavaScript on the basis of the mechanism is added Mozilla, integration with a desktop is improved, some new features in creation of graphical interfaces are added.

Version history

Java 1.0

Development of Java began in 1990, the first official version — Java 1.0 — was issued only in 1995.

Java 2.0

By 1998 the updated JDK 1.2 specification which appeared under the name Java 2 was developed. Actually language changes in this version did not appear. The platform received the following additions:

  • A set of means for creation of a visual user interface of Swing.
  • Collections.
  • Support of files of Policy and digital certificates of the user.
  • Accessibility library.
  • Java 2D.
  • Support of drag-and-drop technology.
  • Full support of Unicode, including support of input in the Japanese, Chinese and Korean languages.
  • Support of reproduction of audio-files of several popular formats.
  • Full support of CORBA technology.
  • The JIT compiler, the improved performance.
  • Improvements of work benches of JDK, including support of profiling of Java programs

Java 5

The Java 5 specification was issued in September, 2004. In this version developers made a number of basic additions to language:

  • Enumerable types (enum). The types which were earlier absent in Java are issued by analogy with C ++, but at the same time have a number of additional opportunities.
    • the Enumerable type is the full-fledged class Java, i.e. the designer, fields, methods, including hidden and abstract can have.
    • Transfer can implement interfaces.
    • For transfers there are built-in methods giving the chance of obtaining values of type by name, the character values corresponding to names, conversions between number and value, checks of type on the fact that it is enumerable.

  • Summaries — a possibility of adding in the text of the program of the metadata which are not influencing accomplishment of the code, but allowing use for obtaining different data on the code and its execution. Tools for use of the annotated code are at the same time released. One of applications of summaries — simplification of creation of test modules for Java code.
  • Means of the generalized programming (generics) — the mechanism similar to templates in C ++ or C#, giving the chance to create classes and methods with fields and parameters of any type. Using this mechanism new versions of collections of standard library Java are implemented.
  • Methods with indefinite number of parameters.
  • Autoboxing/Unboxing is automatic conversion between the scalar Java types and the corresponding types-vrapperami (for example, between int — Integer). Existence of such opportunity simplifies the code as excludes need for accomplishment of explicit type conversions for obvious cases.
  • Import of static variables is resolved.
  • In language it is looped on a collection of objects (iterator).

Java 7

  • In June, 2011 the Oracle company released candidate release of the Java 7 platform. The official release of this long-awaited new version should take place on July 28, 2011. After 5 years of the actual stagnation which passed from the moment of release of Java 6, many users and developers of Java applications wait from the new platform of the serious changes which are bringing closer the Java platform to modern realities.

A set of the new program interfaces API for the organization of input-output under the general name JSR 203 should become the most noticeable innovation in Java 7, according to developers. For the first time the Java technology got this access to real file systems – it allows to work with symbolical links and to get access to functions of each specific file system. The new basic mechanism for branching and consolidation of flows of JSR 166y was processed at the initiative of the famous competitive multitasking specialist Doug Lea. Providing true parallelism, the Java technology is completely ready to work in multinuclear computing environments now. Also the Java 7 platform offers JSR 292 technology which provides support of dynamically typified programming languages in virtual to Java machines (JVM).

The candidate release of Java 7 includes only 13 changes in comparison with the last working assembly of a product. More than a half of these changes are purely administrative corrections, and here the others are these revelations, correcting such hard errors as failures of virtual machines and incorrect JIT broadcasting in the environment of Eclipse.

By Java 9 it is postponed until 2017

On December 2, 2015 developers from Oracle reported that they do not fit into the diagram of preparation of Java 9[6] published earlier[6].

According to the statement, they will need about half a year more to bring the Jigsaw project to the type developing funds of splitting programs and JDK, significant for Java, for modules appropriate to a product.

For December 2, 2015 for a statement the diagram according to which the release of JDK 9 is postponed from September 22, 2016 for March 23, 2017 is prepared. Completion of development of necessary functionality is expected on May 25, 2016, but not on December 10, 2015 as it was planned initially.

Java 14 Exit

In March, 2020 Oracle released Java 14 (Oracle JDK 14) and stated that the new version increases performance of the developers working with the Java programming language. Main innovations following.

  • JEP 305: Pattern Matching for instanceof. Expands functionality of comparison to a template for instanceof operator. It increases labor productivity of the developer, eliminating need for the sample code, and allows to receive more compact and tipobezopasny code.

  • JEP 343: Packaging Tool (incubator). Gives to developers an opportunity to pack the Java applications for distribution in formats, specific to platforms. It helps to create modern applications in the form of a single deliverable batch of libraries in which the environment of execution and an application code are integrated. 

  • JEP 345: NUMA-Aware Memory Allocation for G1yu Increases the overall performance of a garbage collector of G1 in systems with architecture of memory of NUMA (Non-Uniform Memory Access).

  • JEP 349: JFR Event Streaming. Opens data of JDK Flight Recorder (JFR) for continuous monitoring. It will simplify access of different tools and annexes to these JFR and will stimulate further innovations.

  • JEP 358: Helpful NullPointerExceptions. Increases convenience of using of exceptions of NullPointerException, precisely describing what variable was equal to zero, and providing other useful information.

  • JEP 359: Records. Provides compact syntax of the declaration of classes which contain superficial unchangeable data (shallowly immutable). This function can reduce considerably the sample code in classes of this kind, but the biggest advantage – an opportunity to model data as data. 

  • JEP 370: Foreign-Memory Access API. The API interface allowing programs of Java safely and effectively to get access to areas of an external bulk memory out of dynamically distributed heap-memory of Java.[7]

Applications of the Java platform

The following successful projects are implemented with attraction of Java (J2EE) of technologies: Amazon, eBay, Flickr, Google (Gmail), Yandex, LinkedIn.

The following companies are generally focused on Java (J2EE) technologies, but not on .NET though deal as well with the last: SAP, IBM, Oracle.

Main Features

  • automatic control of memory
  • enhanced capabilities of processing of exclusive situations;
  • rich set of means of filtering of input-output;
  • a set of standard collections, such as array, list, flew down, etc.;
  • existence of simple tools for network applications (including with use protocol RMI);
  • existence of the classes allowing to execute HTTP requests and to process answers;
  • the tools for multithreaded applications which are built in language;
  • the unified access to to databases on a basis JDBC and SQLJ.
  • support of templates (starting with version 1.5)

Namespace

The idea of namespaces is realized in Java packets.

Sample program

The program displaying "Hello, World!": <source lang="java"> public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }

Example of use of a collection: <source lang="java"> import java.util.*; public class Sample { public static void main(String[] args) { //Creation of a collection object. <String><String>List strings = new ArrayList(); strings.add("Hello"); strings.add("world"); strings.add("!"); for (String s : strings) { System.out.print(s); System.out.print(" "); } } }

Main ideas

Primitive types

In the Java language only 8 scalar types: boolean, byte, char, short, int, long, float, double.

Classes wrappers of primitive types
  • java.lang.Byte
  • java.lang.Short
  • java.lang.Integer
  • java.lang.Long
  • java.lang.Float
  • java.lang.Double
  • java.lang.Boolean
  • java.lang.Character

Lengths and ranges of values of primitive types are defined by the standard, but not implementation and are specified in the table. The char type was made two-byte for convenience of localization (one of the ideological principles of Java): when there was a standard, there was already Unicode-16, but not Unicode-32. As as a result there is no one-byte type left, added the new byte type. The float and double types can have special values + INFINITY, - INFINITY and "not number" (NaN). For the double type they are designated by Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN; for the float type — also, but with the Float prefix instead of Double. The minimum positive values accepted by the float and double types are standardized too.

Type Length (in bytes) Range or set of values
boolean it is not defined true, false
byte 1 −128..127
char 2 0. 216-1, or 0.65535
short 2 −215.215-1, or −32768.32767
int 4 −231.231-1, or −2147483648.2147483647
long 8 −263.263-1, or approximately −9.2·1018.9.2 · 1018
float 4 - (2-2-23) · 2127. (2-2-23) · 2127, or approximately −3.4·1038.3.4 · 1038 and also - INFINITY, INFINITY, NaN
double 8 - (2-2-52) · 21023. (2-2-52) · 21023, or approximately −1.8·10308.1.8 · 10308 and also - INFINITY, INFINITY, NaN

Such tough standardization was necessary to make language platform and independent that is one of ideological requirements to Java and one of the reasons of its success. Nevertheless one small problem with platform independence nevertheless remained. Some processors use 10-byte registers for intermediate storage of results or by other methods improve the accuracy of calculations. To make Java of the most compatible between the different systems, in early versions any methods of increase in accuracy of calculations were prohibited. However it led to decline in the performance. It became clear that deterioration in accuracy for the sake of platform independence for very few people is necessary if it is necessary to pay for it in deceleration of a programs runtime. After numerous protests this ban was lifted, but added the key word of strictfp prohibiting increase in accuracy.

Conversions at mathematical transactions

In the Java language the following rules work:

  1. If one operand has the double type, another will be transformed to the double type too.
  2. Differently if one operand has the float type, another will be transformed to the float type too.
  3. Differently if one operand has the long type, another will be transformed to the long type too.
  4. Differently both operands will be transformed to the int type.

The last rule distinguishes Java from old implementations of C and C ++ and does the code to safer. So, for example, in the Java language after accomplishment of the code <source lang="java">short x = 50, y = 1000;</source><target lang="java" xml:lang="en">short x = 50, y = 1000; int z = x*y; the value 50000, but not −15536, as in the majority of hopelessly outdated implementations of C and C ++ is appropriated to variable z. In the program compiled by MS VC ++ starting with version 7 and also many other modern compilers (gcc, Intel of C ++, the Borland C ++, Comeau, etc.), the value will be also equal to 50000.

Object variables, objects, links and pointers

In the Java language there are only dynamically created objects. And variables of object type and objects in Java — absolutely different entities. Variables of object type are links, i.e. implicit pointers to dynamically created objects. It is emphasized with syntax of the description of variables. So, it is impossible to write to Java: <source lang="java"> double a[10][20]; Foo b(30); </source> and it is necessary: <source lang="java"> double[][] a = new double[10][20]; Foo b = new Foo(30); </source>

At prisvaivaniye, transfer to subprogrammes and comparisons object variables behave as pointers, i.e. the addresses of objects are appropriated, copied and compared. And at access using an object variable to data fields or methods of an object no special transactions of a razymenovyvaniye are required — this access is provided as if the object variable was an object.

Variables of any type, except simple numerical types are object. There are no explicit pointers in Java. Unlike the pointers C, C ++ and other programming languages, links in Java are highly safe thanks to tight restrictions on their use, in particular:

  • It is impossible to transform an int object or any other primitive type to the pointer or the link and vice versa.
  • Over links it is forbidden to execute transactions ++, −−, +, − or any other arithmetic transactions.
  • Type conversion between links is tightly regulated. Except for links to arrays, it is authorized to transform links only between the inherited type and its successor, and conversion of the inherited type to inheriting should be obviously set and at the runtime check of its conciseness is made. Conversions of links to arrays are resolved only when conversions of their base types are resolved and also there are no dimension conflicts.
  • In Java there are no address operators (&) or takings of an object to the address (*). The asterisk in Java means multiplication, and only. The ampersand (also) means only "bit-by-bit and" (a double ampersand — "logical and").

Thanks to such specially introduced restrictions in Java direct manipulation of memory at the level of physical addresses is impossible (though the links which are not indicating anything are: the value of such link is designated by null).

Duplication of links and cloning

Because object variables are reference, at assignment there is no copying of an object. So, if to write <source lang="java"> Foo foo, bar;

bar = foo; </source> that will come copying of the address from the foo variable in the bar variable. So foo and bar will indicate the same area of memory, i.e. the same object; the attempt to change fields of an object to which the foo variable refers will change an object with which bar apparent variable and vice versa. If it is necessary to receive one more copy of a source object, use or the method (member function, in terminology of C ++) clone () creating the copy of an object, or the copying designer.

The clone method () requires that the class implemented the Cloneable interface (about interfaces see below). If the class implements the Cloneable interface, by default clone () copies all fields (the small copy). If it is required not to copy, and to clone fields (and also their fields and so on), it is necessary to redefine the clone method (). Determination and use of the clone method () often is an uncommon task ().

Garbage collection

In the Java language explicit removal of an object from memory is impossible — instead garbage collection is implemented. The traditional acceptance giving to a garbage collector "hint" on memory release is assignment of a variable of empty null value. It, however, does not mean that the object replaced with null value will be without fail and is immediately deleted. This acceptance only eliminates object reference, i.e. unties the pointer from an object in memory. At the same time it is necessary to consider that an object will not be deleted with a garbage collector while it is indicated at least by one link from the used variables or objects. There are also methods for initiation of forced garbage collection, but is not guaranteed that they will be caused by the performing environment, and they are not recommended to be used for normal work.

Classes and functions

Java is not a procedural language: any function can exist only in a class. It is emphasized by Java language terminology where there are no concepts "function" or "member function" but only a method. Fixed functions also turned into methods. For example, in Java there is no sin function (), and there is a Math.sin method () the class Math (containing, except sin (), the cos methods (), exp (), sqrt (), abs () and many others).

Static methods and fields

In order that it was not necessary to create a class Math object (and other similar classes) every time when it is necessary to cause sin () (and other similar functions), the concept of static methods (static method) is entered (sometimes in Russian they are called static). The static method (mentioned by a key word of static in the description) can be called, without creating an object of its class. Therefore it is possible to write <source lang="java">double x = Math.sin(1);</source><source lang="java">double x = Math.sin(1);</source> instead of <source lang="java">Math m = new Math();</source><target lang="java" xml:lang="en">Math m = new Math(); double x = m.sin(1); The restriction imposed on static methods is that in this object they can address only static fields and methods.

Static fields make the same sense, as in C ++: everyone exists only in the single copy.

Finalnost

The key word of final (final) means different things at the description of a variable, method or class. The final variable is initialized at the description and further cannot be changed. The final method cannot be redefined at inheritance. The final class cannot have successors in general.

Abstractness

In Java the methods which are not announced obviously as final or private are virtual in terminology of C ++: at a method call, differently certain in the basic and inheriting classes, check of runtime is always made.

Abstract method (abstract descriptor) in Java is called the method for which parameters and type of a returned value, but not a body are set. The abstract method is defined in classes successors. In C ++ the same is called purely virtual function. In order that in a class it was possible to describe abstract methods, the class should be described as abstract too. Objects of an abstract class cannot be created because on the extent of memory which needs to be selected a floor an object of such class is not known.

Interfaces

The highest degree of abstractness in Java is the interface (interface). All methods of the interface are abstract: abstract descriptor is not even required. The interface is not a class. The class can inherit, or expand (extends) other class or implement (implements) the interface. Besides, the interface can inherit, or expand other interface.

In Java the class cannot inherit more than one class, but can implement some interfaces.

Interfaces can be transferred to methods as parameters, but it is impossible to create objects of their types.

Marker interfaces

In Java there are some interfaces which do not contain methods for implementation, and JVM are in a special way processed. These are interfaces:

  • java.lang.Cloneable
  • java.io.Serializable
  • java.rmi.Remote

Templates in Java (generics)

Starting with the version of Java 5 in language the mechanism of the generalized programming — the templates externally close to templates C ++ appeared. Using special syntax it is possible to specify parameters types which in the description can be used as types of fields, parameters and returned values of methods in the description of classes and methods.

<source lang="java"> //The declaration of the generalized class class GenericClass<E> { E getFirst() {... } void add(E obj) {... } }

//Use of the generalized class in the code <String><String>GenericClass var = new GenericClass(); var.add("qwerty"); String p = var.getFirst(); </source>

The generalized declaration of classes, interfaces and methods is allowed. Besides, the syntax supports limited declarations of types parameters: the instruction in the declaration of construction of a type<T extends A & B & C...> requires that type parameter T implemented the A, B, C interfaces and so on, and construction<T super C> requires that type parameter T was type C or one from his ancestors.

Unlike the# templates C, the Java templates are not supported by the execution environment — the compiler just creates a bytecode in which there are no templates any more. Implementation of templates in Java essentially differs from sale of similar mechanisms in C ++: the compiler does not generate separate option of a class or a method template for each case of use of a template, and just creates one implementation of a bytecode containing necessary checks and type conversions. It leads to a number of restrictions of use of templates in programs on Java.

Check of belonging to a class

In Java it is possible to check obviously to what class an object belongs. Expression of foo instanceof Foo is true if an object of foo belongs to the class Foo or its successor, or implements the Foo interface (or, in a general view, inherits a class which implements the interface which inherits Foo).

Further, the getClass function (), defined for all objects, issues a Class object. These objects can be compared. So, for example, foo.getClass ()==() will be true bar.getClass if objects of foo and bar belong in accuracy to one class (but it does not mean that it is two identical objects).

Besides, a Class object of any type can be received so: Integer.class, Object.class.

However direct comparison of classes not always is optimal means of check on belonging to a class. Often instead of it use the isAssignableFrom function (). This function is defined at a Class object and accepts a Class object as parameter. Thus, the call of Foo.class.isAssignableFrom (Bar.class) will return true if Foo is an ancestor of the class Bar. As all objects are descendants like Object, a call of Object.class.isAssignableFrom ()<code> will always return <code>true. Together with the mentioned functions of a Class object also the isInstance functions () are used (instanceof is equivalent) and also cast () (will transform parameter to an object of the selected class).

Class libraries

  • JDK — contains a set of base classes for all software on platforms Java SE and Java EE
  • CDK — for creation of chemical software
  • MARF is modular library for recognition of audio

Software development tools

Popularity of Java

2018: The first place in the world

In December, 2018 the Tiobe portal published the regular rating of programming languages based on calculation of results of the search queries containing the name of language. Java remains on the first place. Read more here.

2013: The status of the most popular programming language returned to Java

Despite all problems with security detected recently Java returned itself the first place in monthly popularity rating of the Tiobe Programming Community Index programming languages. Before the whole ten months first place was won by Si. The company Tiobe considers that the popularity of Java grew thanks to success of Android backgrounds.

So, at Java now popularity rating of 18.387%, and at Si — 17.080. Ten also included Objective-C (9.803), C ++ (8.758), C# (6.680), PHP (5.074), Python (4.949), Visual Basic (4.648), Perl (2.252) and Ruby (1.752). The popularity of Python among interpreters grows, and it can soon bypass PHP, believe in Tiobe.

Estimate popularity of languages at Tiobe by the number of programmers, training courses and suppliers of work benches. The first place of Java confirms one more rating, PyPL Popularity of Language according to which result of language of 29%. PyPL has other technique of calculation — by the number of the search queries concerning the guides to programming languages. According to PyPL, on the second place now PHP (14.6), follow it to the C# (10.5), Python (10.3), C ++ (9.8), C (9.6), JavaScript (7.5), Visual Basic (3.8), Ruby (2.9) and Perl (1.9).

Java и Microsoft

The company Microsoft developed own implementation of JVM (MSJVM) which was included different OS since Windows 95. MSJVM was close to Sun Microsystems the v.1.1.3 specification, but did not correspond to it on a number of basic characteristics (in particular, on lack of support of technologies RMI and JNI and to existence of non-standard expansions). Afterwards it was a reason for legal claims from outside Sun Microsystems to Microsoft. The court sided with SUN Microsystems company. Eventually between two companies the agreement on a possibility of prolongation of term of official user support of non-standard Microsoft of JVM until the end of 2007, but[8] was reached[9]. Now the company Microsoft for the platform .NET offers the Java-like language J# which is not meeting the official language specification Java.

20-year anniversary of Java

On May 23, 2015 20 years of day of a release of the first version of Java were performed.

In Oracle twenty-year anniversary since emergence of Java noted a noisy marketing effort[10].

When Java was provided by the SUN Microsystems company purchased by Oracle in 2010 it there was still mostly a "dointernetovsky" era, and the world landscape of IT strongly differed from present. Nevertheless Java still remains in "a box of tools" of the developer, and many other languages which were widely used in the 1990th, such as Delphi or Perl, were out of work or are applied only to a limited circle of tasks.

According to Oracle developers of the Java platform, the main value of Java — legibility and simplicity.

For May 23, 2015 at least one language on application width in the computer industry will hardly be compared to Java. By estimates of Oracle, Java use more than 9 million developers and it is used in 7 billion devices. Java works with "engine", both in very small devices, and in the large systems of cloud computing.

Google made Java the main language of writing of programs for Android. On other end of a range — Map/Reduce framework for the Hadoop platform relying on Java for processing of petabytes of data. Programmers love Java including because language is easily read in comparison with the impassable "jungle" which sometimes is found in the code on C ++ or Perl.

Legibility — very valuable feature for the programming language which is especially used for software development of the enterprise level he explained. So far as concerns a complex system, the programmer needs an opportunity to understand the code which was written months or years ago.

For benefit of Java there were also other characteristics. One of them — accomplishment of the slogan "it is written once, works everywhere" advertized in due time. As the code is executed on the cross-platform Java virtual machine, it is possible to write the program on the notebook with Windows, and it can work on the server with Linux or Solaris without recompilation.

IDC consider, thanks to long-term preserving of backward compatibility and also "methodical development" of language its popularity remains high. Use of Java in Android and competent actions of Oracle platforms definitely prolonged life, having provided demand for developers with the corresponding skills.

Oracle develops language, maintaining its attractiveness. In plans of corporation, in Java 9 release, preparing for September, 2016, language will be reorganized and brought to modular architecture.

See Also

Links

Literature

Notes