java programming language java language redirects here for the natural language from the indonesian island of java see javanese language this article is about a programming language for the software platform see java software platform for the software package downloaded from javacom see java se not to be confused with javascript java is a generalpurpose computerprogramming language that is concurrent classbased objectoriented java was originally developed by james gosling at sun microsystems which has since been acquired by oracle corporation and released in 1995 as a core component of sun microsystems java platform the language derives much of its syntax from c and c but it has fewer lowlevel facilities than either of them the original and reference implementation java compilers virtual machines and class libraries were originally released by sun under proprietary licenses as of may 2007 in compliance with the specifications of the java community process sun relicensed most of its java technologies under the gnu general public license others have also developed alternative implementations of these sun technologies such as the gnu compiler for java bytecode compiler gnu classpath standard libraries and icedteaweb browser plugin for applets the latest version is java 11 released on september 25 2018 which follows java 10 after only six months prejava 8 from at least windows computers history see also java software platform history duke the java mascot james gosling the creator of java in 2008 the tiobe programming language popularity index graph from 2002 to 2018 over the course of a decade java blue and c black competed for the top position james gosling mike sheridan and patrick naughton initiated the java language project in june 1991 sun microsystems released the first public implementation as java 10 in 1996 with the advent of java 2 released initially as j2se 12 in december 1998 1999 new versions had multiple configurations built for different types of platforms j2ee included technologies and apis for enterprise applications typically run in server environments while j2me featured apis optimized for mobile applications the desktop version was renamed j2se in 2006 for marketing purposes sun renamed new j2 versions as java ee java me and java se respectively in 1997 sun microsystems approached the isoiec jtc 1 standards body and later the ecma international to formalize java but it soon withdrew from the process at one time sun made most of its java implementations available without charge despite their proprietary software status sun generated revenue from java through the selling of licenses for specialized products such as the java enterprise system on november 13 2006 sun released much of its java virtual machine jvm as free and opensource software foss under the terms of the gnu general public license gpl on may 8 2007 sun finished the process making all of its jvms core code available under free softwareopensource distribution terms aside from a small portion of code to which sun did not hold the copyright suns vicepresident rich green said that suns ideal role with regard to java was as an evangelist in january 2016 oracle announced that java runtime environments based on jdk 9 will discontinue the browser plugin principles there were five primary goals in the creation of the java language it must be simple objectoriented and familiar it must be robust and secure it must be architectureneutral and portable it must execute with high performance it must be interpreted threaded and dynamic versions java version history as of 20march2018 both java 8 and 11 are officially supported major release versions of java along with their release dates jdk 10 january 23 1996 jdk 11 february 19 1997 j2se 12 december 8 1998 j2se 13 may 8 2000 j2se 14 february 6 2002 j2se 50 september 30 2004 java se 6 december 11 2006 java se 7 july 28 2011 java se 8 march 18 2014 java se 9 september 21 2017 java se 10 march 20 2018 java se 11 september 25 2018 editions see also free java implementations class library java platform editions java card micro edition me standard edition se enterprise edition ee javafx bundled in jre from 8 to 10 but separately for javafx 1x 2x and 11 personaljava discontinued vte sun has defined and supports four editions of java targeting different application environments and segmented many of its apis so that they belong to one of the platforms the platforms are java card for smartcards java platform micro edition java me targeting environments with limited resources java platform standard edition java se targeting workstation environments java platform enterprise edition java ee targeting large distributed enterprise or internet environments the classes in the java apis are organized into separate groups called packages each package contains a set of related interfaces classes and exceptions refer to the separate platforms for a description of the packages available sun also provided an edition called personaljava that has been superseded by later standardsbased java me configurationprofile pairings execution system java jvm and bytecode java software platform and java virtual machine one design goal of java is portability which means that programs written for the java platform must run similarly on any combination of hardware and operating system with adequate runtime support this is achieved by compiling the java language code to an intermediate representation called java bytecode instead of directly to architecturespecific machine code java bytecode instructions are analogous to machine code but they are intended to be executed by a virtual machine vm written specifically for the host hardware end users commonly use a java runtime environment jre installed on their own machine for standalone java applications or in a web browser for java applets standard libraries provide a generic way to access hostspecific features such as graphics threading and networking the use of universal bytecode makes porting simple however the overhead of interpreting bytecode into machine instructions made interpreted programs almost always run more slowly than native executables justintime jit compilers that compile bytecodes to machine code during runtime were introduced from an early stage java itself is platformindependent and is adapted to the particular platform it is to run on by a java virtual machine for it which translates the java bytecode into the platforms machine language performance java performance programs written in java have a reputation for being slower and requiring more memory than those written in c the addition of language features supporting better code analysis such as inner classes the stringbuilder class optional assertions etc and optimizations in the java virtual machine such as hotspot becoming the default for suns jvm in 2000 with java 15 the performance was improved with the addition of the javautilconcurrent package including lock free implementations of the concurrentmaps and other multicore collections and it was improved further with java 16 nonjvm some platforms offer direct hardware support for java there are microcontrollers that can run java bytecode in hardware instead of a software java virtual machine and some arm based processors could have hardware support for executing java bytecode through their jazelle option though support has mostly been dropped in current implementations of arm automatic memory management java uses an automatic garbage collector to manage memory in the object lifecycle the programmer determines when objects are created and the java runtime is responsible for recovering the memory once objects are no longer in use once no references to an object remain the unreachable memory becomes eligible to be freed automatically by the garbage collector something similar to a memory leak may still occur if a programmers code holds a reference to an object that is no longer needed typically when objects that are no longer needed are stored in containers that are still in use if methods for a nonexistent object are called a null pointer exception is thrown one of the ideas behind javas automatic memory management model is that programmers can be spared the burden of having to perform manual memory management in some languages memory for the creation of objects is implicitly allocated on the stack or explicitly allocated and deallocated from the heap in the latter case the responsibility of managing memory resides with the programmer if the program does not deallocate an object a memory leak occurs if the program attempts to access or deallocate memory that has already been deallocated the result is undefined and difficult to predict and the program is likely to become unstable or crash this can be partially remedied by the use of smart pointers but these add overhead and complexity note that garbage collection does not prevent logical memory leaks ie those where the memory is still referenced but never used garbage collection may happen at any time ideally it will occur when a program is idle it is guaranteed to be triggered if there is insufficient free memory on the heap to allocate a new object this can cause a program to stall momentarily explicit memory management is not possible in java java does not support cc style pointer arithmetic where object addresses and unsigned integers usually long integers can be used interchangeably this allows the garbage collector to relocate referenced objects and ensures type safety and security as in c and some other objectoriented languages variables of javas primitive data types are either stored directly in fields for objects or on the stack for methods rather than on the heap as is commonly true for nonprimitive data types but see escape analysis this was a conscious decision by javas designers for performance reasons java contains multiple types of garbage collectors by default hotspot uses the parallel scavenge garbage collector syntax java syntax dependency graph of the java core classes created with jdeps and gephi the most frequently used classes object and string appear in the centre of the diagram the syntax of java is largely influenced by c unlike c which combines the syntax for structured generic and objectoriented programming java was built almost exclusively as an objectoriented language all code is written inside classes and every data item is an object with the exception of the primitive data types ie integers floatingpoint numbers boolean values and characters which are not objects for performance reasons java reuses some popular aspects of c such as the printf method unlike c java does not support operator overloading java uses comments similar to those of c there are three different styles of comments a single line style marked with two slashes a multiple line style opened with and closed with and the javadoc commenting style opened with and closed with the javadoc style of commenting allows the user to run the javadoc executable to create documentation for the program and can be read by some integrated development environments ides such as eclipse to allow developers to access documentation within the ide hello world example the traditional hello world program can be written in java as class helloworldapp public static void mainstring args systemoutprintlnhello world prints the string to the console source files must be named after the public class they contain appending the suffix java for example helloworldappjava it must first be compiled into bytecode using a java compiler producing a file named helloworldappclass only then can it be executed or launched the java source file may only contain one public class but it can contain multiple classes with other than public access modifier and any number of public inner classes when the source file contains multiple classes make one class public and name the source file with that public class name a class that is not declared public may be stored in any java file the compiler will generate a class file for each class defined in the source file the name of the class file is the name of the class with class appended for class file generation anonymous classes are treated as if their name were the concatenation of the name of their enclosing class a and an integer the keyword public denotes that a method can be called from code in other classes or that a class may be used by classes outside the class hierarchy the class hierarchy is related to the name of the directory in which the java file is located this is called an access level modifier other access level modifiers include the keywords private and protected the keyword static in front of a method indicates a static method which is associated only with the class and not with any specific instance of that class only static methods can be invoked without a reference to an object static methods cannot access any class members that are not also static methods that are not designated static are instance methods and require a specific instance of a class to operate the keyword void indicates that the main method does not return any value to the caller if a java program is to exit with an error code it must call systemexit explicitly the method name main is not a keyword in the java language it is simply the name of the method the java launcher calls to pass control to the program java classes that run in managed environments such as applets and enterprise javabeans do not use or need a main method a java program may contain multiple classes that have main methods which means that the vm needs to be explicitly told which class to launch from the main method must accept an array of string objects by convention it is referenced as args although any other legal identifier name can be used since java 5 the main method can also use variable arguments in the form of public static void mainstring args allowing the main method to be invoked with an arbitrary number of string arguments the effect of this alternate declaration is semantically identical to the args parameter which is still an array of string objects but it allows an alternative syntax for creating and passing the array the java launcher launches java by loading a given class specified on the command line or as an attribute in a jar and starting its public static void mainstring args parameter is an array of string objects containing any arguments passed to the class the parameters to main are often passed by means of a command line printing is part of a java standard library the system class defines a public static field called out the out object is an instance of the printstream class and provides many methods for printing data to standard out including printlnstring which also appends a new line to the passed string the string hello world is automatically converted to a string object by the compiler example with methods this is an example of a single line comment using two slashes this is an example of a multiple line comment using the slash and asterisk this type of comment can be used to hold a lot of information or deactivate code but it is very important to remember to close the comment package fibsandlies import javautilhashmap this is an example of a javadoc comment javadoc can compile documentation from this text javadoc comments must immediately precede the class method or field being documented public class fibcalculator extends fibonacci implements calculator private static mapinteger integer memoized new hashmapinteger integer the main method written as follows is used by the jvm as a starting point for the program public static void mainstring args memoizedput1 1 memoizedput2 1 systemoutprintlnfibonacci12 get the 12th fibonacci number and print to console an example of a method written in java wrapped in a class given a nonnegative number fibindex returns the nth fibonacci number where n equals fibindex param fibindex the index of the fibonacci number return the fibonacci number public static int fibonacciint fibindex if memoizedcontainskeyfibindex return memoizedgetfibindex else int answer fibonaccifibindex 1 fibonaccifibindex 2 memoizedputfibindex answer return answer special classes applet java applet java applets were programs that were embedded in other applications typically in a web page displayed in a web browser the java applet api is now deprecated since java 9 in 2017 servlet java servlet java servlet technology provides web developers with a simple consistent mechanism for extending the functionality of a web server and for accessing existing business systems servlets are serverside java ee components that generate responses typically html pages to requests typically http requests from clients the java servlet api has to some extent been superseded by two standard java technologies for web services the java api for restful web services jaxrs 20 useful for ajax json and rest services and the java api for xml web services jaxws useful for soap web services javaserver pages javaserver pages javaserver pages jsp are serverside java ee components that generate responses typically html pages to http requests from clients jsps embed java code in an html page by using the special delimiters and a jsp is compiled to a java servlet a java application in its own right the first time it is accessed after that the generated servlet creates the response swing application swing java swing is a graphical user interface library for the java se platform it is possible to specify a different look and feel through the pluggable look and feel system of swing clones of windows gtk and motif are supplied by sun apple also provides an aqua look and feel for macos where prior implementations of these looks and feels may have been considered lacking swing in java se 6 addresses this problem by using more native gui widget drawing routines of the underlying platforms generics generics in java in 2004 generics were added to the java language as part of j2se 50 prior to the introduction of generics each variable declaration had to be of a specific type for container classes for example this is a problem because there is no easy way to create a container that accepts only specific types of objects either the container operates on all subtypes of a class or interface usually object or a different container class has to be created for each contained class generics allow compiletime type checking without having to create many container classes each containing almost identical code in addition to enabling more efficient code certain runtime exceptions are prevented from occurring by issuing compiletime errors if java prevented all runtime type errors classcastexceptions from occurring it would be type safe in 2016 the type system of java was proven unsound criticism criticism of java criticisms directed at java include the implementation of generics class libraries java class library the java class library is the standard library developed to support application development in java it is controlled by sun microsystems in cooperation with others through the java community process program companies or individuals participating in this process can influence the design and development of the apis this process has been a subject of controversy the class library contains features such as the core libraries which include ionio networking reflection concurrency generics scriptingcompiler functional programming lambda streaming collection libraries that implement data structures such as lists dictionaries trees sets queues and doubleended queue or stacks xml processing parsing transforming validating libraries security internationalization and localization libraries the integration libraries which allow the application writer to communicate with external systems these libraries include the java database connectivity jdbc api for database access java naming and directory interface jndi for lookup and discovery rmi and corba for distributed application development jmx for managing and monitoring applications user interface libraries which include the heavyweight or native abstract window toolkit awt which provides gui components the means for laying out those components and the means for handling events from those components the lightweight swing libraries which are built on awt but provide nonnative implementations of the awt widgetry apis for audio capture processing and playback javafx a platform dependent implementation of the java virtual machine that is the means by which the bytecodes of the java libraries and third party applications are executed plugins which enable applets to be run in web browsers java web start which allows java applications to be efficiently distributed to end users across the internet licensing and documentation documentation javadoc javadoc is a comprehensive documentation system created by sun microsystems used by many java developers implementations see also free java implementations oracle corporation is the current owner of the official implementation of the java se platform following their acquisition of sun microsystems on january 27 2010 this implementation is based on the original implementation of java by sun the oracle implementation is available for microsoft windows still works for xp while only later versions are currently officially supported macos linux and solaris because java lacks any formal standardization recognized by ecma international isoiec ansi or other thirdparty standards organization the oracle implementation is the de facto standard the oracle implementation is packaged into two different distributions the java runtime environment jre which contains the parts of the java se platform required to run java programs and is intended for end users and the java development kit jdk which is intended for software developers and includes development tools such as the java compiler javadoc jar and a debugger openjdk is another notable java se implementation that is licensed under the gnu gpl the implementation started when sun began releasing the java source code under the gpl as of java se 7 openjdk is the official java reference implementation the goal of java is to make all implementations of java compatible historically suns trademark license for usage of the java brand insists that all implementations be compatible this resulted in a legal dispute with microsoft after sun claimed that the microsoft implementation did not support rmi or jni and had added platformspecific features of their own sun sued in 1997 and in 2001 won a settlement of us20million as well as a court order enforcing the terms of the license from sun as a result microsoft no longer ships java with windows platformindependent java is essential to java ee and an even more rigorous validation is required to certify an implementation this environment enables portable serverside applications use outside the java platform the java programming language requires the presence of a software platform in order for compiled programs to be executed oracle supplies the java platform for use with java the android sdk is an alternative software platform used primarily for developing android applications with its own gui system the eclipse ide platform supports java but provides its own gui system swt android the android operating system makes extensive use of javarelated technology the java language is a key pillar in android an open source mobile operating system although android built on the linux kernel is written largely in c the android sdk uses the java language as the basis for android applications the bytecode language supported by the android sdk is incompatible with java bytecode and runs on its own virtual machine optimized for lowmemory devices such as smartphones and tablet computers depending on the android version the bytecode is either interpreted by the dalvik virtual machine or compiled into native code by the android runtime android does not provide the full java se standard library although the android sdk does include an independent implementation of a large subset of it it supports java 6 and some java 7 features offering an implementation compatible with the standard library apache harmony controversy see also oracle america inc v google inc the use of javarelated technology in android led to a legal dispute between oracle and google on may 7 2012 a san francisco jury found that if apis could be copyrighted then google had infringed oracles copyrights by the use of java in android devices java programming language portal computer programming portal book programming for students dalvik used in old android versions replaced by nonjit android runtime javaone javapedia list of java virtual machines list of java apis list of jvm languages graalvm a high performance java dynamic compiler and interpreter comparison of java with other languages comparison of programming languages comparison of java and c comparison of c and java notes gosling james joy bill steele guy bracha gilad buckley alex 2014 the java language specification pdf java se 8 ed gosling james joy bill steele guy l jr bracha gilad 2005 the java language specification 3rd ed addisonwesley isbn0321246780 lindholm tim yellin frank 1999 the java virtual machine specification 2nd ed addisonwesley isbn0201432943 java programming languageat wikipedias sister projects definitions from wiktionary media from wikimedia commons news from wikinews quotations from wikiquote textbooks from wikibooks resources from wikiversity wikiversity has learning resources about java platform enterprise editionjava ee tutorial vtejavaplatforms java language jvm micro edition standard edition enterprise edition java card android sdk oracle technologies squawk java development kit openjdk java virtual machine javafx maxine vm platform technologies applets servlets midlets jsp jsf web start jnlp major thirdparty technologies blackdown eclipse gnu classpath gwt harmony hibernate icedtea jazelle spring struts toplink wildfly history java version history java community process sun microsystems free java implementations major jvm languages beanshell clojure groovy oxygene jruby jython kotlin processing rhino scala tcljava communityconferences javaone devoxx developers apache software foundation java community process oracle corporation sun microsystems sun microsystems laboratories people james gosling arthur van hoff urs hlzle patrick naughton category portal vtesun microsystems acquired by oracle corp 2010hardware sun1 sun2 sun3 sun386i sun4 sparcstation netra ultra enterprise sun blade sun fire sparc enterprise sparc javastation sun ray sun modular datacenter more software sunos solaris nis nfs zfs sunview news openwindows java desktop system sun studio java staroffice iplanet sun one java enterprise system sun secure global desktop mysql sun xvm glassfish more storage storagetek sun open storage qfs zfs highperformance computing sun cloud sun constellation system sun visualization system sun grid engine lustre research sun labs picojava fortress project looking glass education scps bluej community common development and distribution license java community process netbeans openofficeorg opensolaris opensparc openjdk osum people bill joy andy bechtolsheim scott mcnealy vinod khosla list of notable employees vteoracle corporationcorporate directors jeffrey berg h raymond bingham michael boskin safra catz larry ellison hctor garcamolina joseph grundfest jeffrey o henley mark hurd jack f kemp donald l lucas naomi o seligman acquisitions list sun peoplesoft hyperion siebel bea jd edwards rightnow virtual iron timesten sunopsis netsuite dbms oracle database mysql innodb berkeley db timesten rdb essbase programming languages java plsql ide jdeveloper forms netbeans apex sql developer developer studio middleware fusion middleware webcenter soa suite weblogic server coherence tuxedo glassfish operating systems oracle linux oracle solaris computer hardware sun fire sparc tseries enterprise storagetek computer appliances oracle exadata oracle exalogic big data appliance education and recognition oracle certification program category commons vteprogramming languages comparison timeline history apl assembly basic c c c cobol fortran go groovy haskell java javascript js kotlin lisp lua objectivec pascal perl php python ruby rust shell smalltalk swift visual basic net vbnet more category lists alphabetical categorical generational nonenglishbased vtefree and opensource softwaregeneral alternative terms for free software comparison of opensource and closedsource software comparison of source code hosting facilities free software free software project directories gratis versus libre longterm support opensource software opensource software development outline softwarepackages audio bioinformatics codecs collaboration configuration management device drivers graphics wireless geophysics health mathematics operating systems programming languages routing statistics television video games web applications content management systems ecommerce word processors android apps ios apps commercial trademarked formerly proprietary community free software movement history opensource software movement organizations events licenses afl apache apsl artistic beerware boost bsd cc0 cddl epl free software foundation gnu gpl gnu lgpl isc mit mpl msplrl python python software foundation license sleepycat unlicense wtfpl zlib types and standards comparison of free and opensource software licenses contributor license agreement copyleft debian free software guidelines definition of free cultural works free license the free software definition the open source definition opensource license permissive software licence public domain viral license challenges binary blob digital rights management hardware restrictions license proliferation mozilla software rebranding proprietary software scolinux controversies secure boot software patents software security trusted computing related topics forking gnu manifesto microsoft open specification promise opencore model opensource hardware shared source initiative sourceavailable software the cathedral and the bazaar revolution os book category commons portal authority control bne xx540033 bnf cb12533207m data gnd 44013139 lccn sh95008574 