Revision as of 11:00, 13 June 2008 view sourceKlausness (talk | contribs)Extended confirmed users, Rollbackers2,400 edits rv; not really relevant... Java programs won't run if you don't have a JVM installed, either... platform-independence here clearly assumes that the appropriate JVM is installed← Previous edit | Latest revision as of 06:14, 2 January 2025 view source Tkmcinto (talk | contribs)58 editsm →Generics: Add missing word ("of"). | ||
Line 1: | Line 1: | ||
{{pp-semi-indef|small=yes}} | |||
{{redirect|Java language|the Indonesian spoken language|Javanese language}} | |||
{{Short description|Object-oriented programming language}} | |||
{{distinguish|JavaScript}} | |||
{{Distinguish|Java (software platform)|JavaScript|Java|Javanese language}} | |||
{{otheruses2|Java}} | |||
{{Redirect|Openframe|the ten-pin bowling term|Open frame}} | |||
{{ infobox programming language | |||
{{Use mdy dates|date=August 2017}} | |||
| name = Java | |||
| logo = ] | |||
{{Infobox programming language | |||
| paradigm = ], ], ] | |||
| name = Java | |||
| year = ] | |||
| logo = Java programming language logo.svg | |||
| designer = ] | |||
| logo size = 121px | |||
| latest_release_version = Java Standard Edition 6 (1.6.0) | |||
| logo caption = | |||
| latest_release_date = | |||
| paradigm = ]: ], ] (]), ], ], ], ] | |||
| latest_test_version = | |||
| year = {{Start date and age|1995|5|23}}<ref>{{cite magazine|url=https://www.forbes.com/sites/oracle/2015/05/20/javas-20-years-of-innovation/|title=Java's 20 Years of Innovation|magazine=Forbes|date=May 20, 2015|access-date=March 18, 2016|author=Binstock, Andrew|archive-url=https://web.archive.org/web/20160314102242/http://www.forbes.com/sites/oracle/2015/05/20/javas-20-years-of-innovation/|archive-date=March 14, 2016|url-status=live}}</ref> | |||
| latest_test_date = | |||
| discontinued = <!-- Set to yes if software is discontinued, otherwise omit. --> | |||
| turing-complete = Yes | |||
| ver layout = <!-- simple (default) or stacked --> | |||
| typing = ], ] | |||
| latest release version = {{wikidata|property|edit|reference|P548=Q2804309|P348}} | |||
| implementations = Numerous | |||
| latest release date = {{start date and age|{{wikidata|qualifier|single|P548=Q2804309|P348|P577}}}} | |||
| influenced_by = ], ], ], ]<ref>{{ cite web | authors = Gosling and McGilton | title = The Java Language Environment | date= May 1996 | url = http://java.sun.com/docs/white/langenv/ }}</ref>, ], ]<ref>{{ | |||
| designer = ] | |||
cite web | authors = J. Gosling, B. Joy, G. Steele, G. Brachda | title = The Java Language Specification, 2nd Edition | url= http://java.sun.com/docs/books/jls/second_edition/html/intro.doc.html#237601 }}</ref>, ]<ref>Java 5.0 added several new language features (the ], ], ] and ]), after they were introduced in the similar (and competing) ] language. </ref> | |||
| developer = ] | |||
| influenced = ], ], ], ], ], ], ] | |||
| typing = ], ], ] | |||
| operating_system = ] | |||
| memory management = ] | |||
| license = ] / ] | |||
| influenced_by = ],<ref name="BarbaraLiskov">{{cite book |title=Program Development in Java – Abstraction, Specification, and Object-Oriented Design|author=] with ]|isbn=978-0-201-65768-5|publisher=USA, Addison Wesley|year=2000}}</ref> ],<ref name="BarbaraLiskov" /> ],<ref name="BarbaraLiskov" /> ],<ref name="BarbaraLiskov" /> ], ],<ref>{{cite web|url=https://books.google.com/books?id=0rUtBAAAQBAJ&pg=PAPA133|title=Cracking The Java Programming Interview :: 2000+ Java Interview Que/Ans|first=Harry H.|last=Chaudhary|access-date=2016-05-29|date=2014-07-28|archive-date=September 29, 2023|archive-url=https://web.archive.org/web/20230929040943/https://books.google.com/books?id=0rUtBAAAQBAJ&pg=PAPA133#v=onepage&q&f=false|url-status=live}}</ref> ],<ref>Java 5.0 added several new language features (the ], ], ] and ]), after they were introduced in the similar (and competing) ] language. {{Webarchive|url=https://web.archive.org/web/20110319065438/http://www.barrycornelius.com/papers/java5/|date=March 19, 2011}} {{Webarchive|url=https://web.archive.org/web/20060107162045/http://www.levenez.com/lang/|date=January 7, 2006}}</ref> ],<ref>{{cite web|author1=Gosling, James|author2=McGilton, Henry|title=The Java Language Environment|date=May 1996|url=https://www.oracle.com/technetwork/java/langenv-140151.html|access-date=May 6, 2014|archive-url=https://web.archive.org/web/20140506214653/http://www.oracle.com/technetwork/java/langenv-140151.html|archive-date=May 6, 2014 |url-status=live}}</ref> ],<ref>{{cite web|author1=Gosling, James|author2=Joy, Bill |author3=Steele, Guy|author4=Bracha, Gilad|title=The Java Language Specification, 2nd Edition |url=https://java.sun.com/docs/books/jls/second_edition/html/intro.doc.html#237601|access-date=February 8, 2008|archive-url=https://web.archive.org/web/20110805051057/http://java.sun.com/docs/books/jls/second_edition/html/intro.doc.html#237601|archive-date=August 5, 2011 |url-status=live}}</ref> ],<ref>{{cite web |url=http://www.computerworld.com.au/index.php/id;1422447371;pp;3;fp;4194304;fpid;1|title=The A-Z of Programming Languages: Modula-3 |publisher=Computerworld|access-date=2010-06-09|url-status=dead|archive-url=https://web.archive.org/web/20090105145818/http://www.computerworld.com.au/index.php/id%3B1422447371%3Bpp%3B3%3Bfp%3B4194304%3Bfpid%3B1|archive-date=January 5, 2009}}</ref> ],<ref>] stated on a number of public occasions, e.g. in a lecture at the Polytechnic Museum, Moscow in September 2005 (several independent first-hand accounts in Russian exist, e.g. one with an audio recording: {{cite web|author=Filippova, Elena|title=Niklaus Wirth's lecture at the Polytechnic Museum in Moscow|date=September 22, 2005|url=http://www.delphikingdom.com/asp/viewitem.asp?catalogid=1155|access-date=November 20, 2011|archive-date=December 1, 2020|archive-url=https://web.archive.org/web/20201201054813/http://www.delphikingdom.com/asp/viewitem.asp?catalogid=1155|url-status=live}}), that the Sun Java design team licensed the Oberon compiler sources a number of years prior to the release of Java and examined it: a (relative) compactness, type safety, garbage collection, no multiple inheritance for classes{{snd}} all these key overall design features are shared by Java and Oberon.</ref> ],<ref>] cites ] as a strong influence on the design of the Java programming language, stating that notable direct derivatives include Java interfaces (derived from Objective-C's ]) and primitive wrapper classes. {{Webarchive|url=https://web.archive.org/web/20110713014816/http://cs.gmu.edu/~sean/stuff/java-objc.html|date=July 13, 2011}}</ref> ],<ref>{{cite web |url=http://www.fscript.org/prof/javapassport.pdf |quote=The project went ahead under the name ''green'' and the language was based on an old model of ], which makes it possible to generate interpretive code. |title=History of Java|work=Java Application Servers Report|author=TechMetrix Research|year=1999|archive-url=https://web.archive.org/web/20101229090912/http://www.fscript.org/prof/javapassport.pdf|archive-date=December 29, 2010|url-status=dead}}</ref><ref>{{cite web |title=A Conversation with James Gosling – ACM Queue |date=August 31, 2004 |url=http://queue.acm.org/detail.cfm?id=1017013 |publisher=Queue.acm.org |access-date=2010-06-09|archive-url=https://web.archive.org/web/20150716194245/http://queue.acm.org/detail.cfm?id=1017013|archive-date=July 16, 2015 |url-status=live}}</ref> ]<ref>{{cite report |author=((The Java Language Team)) |publisher=JavaSoft, Sun Microsystems, Inc. |url=http://java.sun.com/docs/white/delegates.html |quote=In the summer of 1996, Sun was designing the precursor to what is now the event model of the AWT and the JavaBeans component architecture. Borland contributed greatly to this process. We looked very carefully at Delphi Object Pascal and built a working prototype of bound method references in order to understand their interaction with the Java programming language and its APIs. |archive-url=https://web.archive.org/web/20120627043929/http://java.sun.com/docs/white/delegates.html |archive-date=2012-06-27 |url-status=dead |type=White Paper |title=About Microsoft's "Delegates"}}</ref> | |||
| website = http://java.sun.com | |||
| influenced = ], ], ], ],<ref name="chplspec">{{cite web|title=Chapel spec (Acknowledgements)|url=http://chapel.cray.com/spec/spec-0.98.pdf|date=2015-10-01|access-date=2016-01-14|publisher=Cray Inc.|archive-url=https://web.archive.org/web/20160205114946/http://chapel.cray.com/spec/spec-0.98.pdf|archive-date=February 5, 2016|url-status=live}}</ref> ], ], ], ],<ref name="gambas">{{cite web|url=http://gambaswiki.org/doc/intro?nh&l=en|title=Gambas Documentation Introduction|publisher=Gambas Website|access-date=2017-10-09|archive-url=https://web.archive.org/web/20171009041815/http://gambaswiki.org/doc/intro?nh&l=en|archive-date=October 9, 2017|url-status=live}}</ref> ], ],<ref>{{cite magazine|url=http://www.infoworld.com/article/2610885/facebook-q-a--hack-brings-static-typing-to-php-world.html|title=Facebook Q&A: Hack brings static typing to PHP world|magazine=InfoWorld|date=March 26, 2014|access-date=2015-01-11|archive-url=https://web.archive.org/web/20150213220946/http://www.infoworld.com/article/2610885/facebook-q-a--hack-brings-static-typing-to-php-world.html|archive-date=February 13, 2015|url-status=live}}</ref> ], ], ], ], ], ], ], ], ], ], ] | |||
| website = {{ubl|{{URL|oracle.com/java/}}|{{URL|java.com}}|{{URL|dev.java}}}} | |||
| file_ext = .java, ], ], .jmod, ] | |||
| wikibooks = Java Programming | |||
}} | }} | ||
'''Java''' is a ], ], ] ] that is designed to have as few implementation ] as possible. It is a ] programming language intended to let ]s ''write once, run anywhere'' (]),<ref>{{cite web|title=Write once, run anywhere?|date=May 2, 2002 |publisher=] |url=http://www.computerweekly.com/Articles/2002/05/02/186793/write-once-run-anywhere.htm|access-date=2009-07-27|url-status=live|archive-date=August 13, 2021|archive-url=https://web.archive.org/web/20210813193857/https://www.computerweekly.com/feature/Write-once-run-anywhere}}</ref> meaning that ] Java code can run on all platforms that support Java without the need to recompile.<ref name="design_goals">{{cite web |title=1.2 Design Goals of the Java Programming Language|date=January 1, 1999 |url=https://www.oracle.com/technetwork/java/intro-141325.html|access-date=2013-01-14|publisher=Oracle|archive-url=https://web.archive.org/web/20130123204103/http://www.oracle.com/technetwork/java/intro-141325.html|archive-date=January 23, 2013|url-status=live}}</ref> Java applications are typically compiled to ] that can run on any ] (JVM) regardless of the underlying ]. The ] of Java is similar to ] and ], but has fewer ] facilities than either of them. The Java runtime provides dynamic capabilities (such as ] and runtime code modification) that are typically not available in traditional compiled languages. | |||
'''Java''' is a ] originally developed by ] and released in 1995 as a core component of Sun Microsystems' ]. The language derives much of its ] from ] and ] but has a simpler ] and fewer low-level facilities. Java applications are typically ] to ] that can run on any ] (JVM) regardless of ]. | |||
Java gained popularity shortly after its release, and has been a popular programming language since then.<ref>{{Cite web |last=Melanson |first=Mike |date=August 9, 2022 |title=Don't call it a comeback: Why Java is still champ |url=https://github.com/readme/featured/java-programming-language |url-status=live |archive-url=https://web.archive.org/web/20230825195416/https://github.com/readme/featured/java-programming-language |archive-date=August 25, 2023 |access-date=October 15, 2023 |website=]}}</ref> Java was the third most popular programming language in {{As of|2022|bare=yes}} according to ].<ref>{{Cite web |title=The top programming languages |url=https://octoverse.github.com/2022/top-programming-languages |url-status=live |archive-url=https://web.archive.org/web/20230802203718/https://octoverse.github.com/2022/top-programming-languages |archive-date=2 August 2023 |access-date=15 October 2023 |website=The State of the Octoverse |publisher=]}}</ref> Although still widely popular, there has been a gradual decline in use of Java in recent years with ] gaining popularity.<ref name=":0">{{cite magazine |last=McMillan |first=Robert |date=August 1, 2013 |title=Is Java Losing Its Mojo? |url=https://www.wired.com/2013/01/java-no-longer-a-favorite/ |url-access=limited |url-status=live |magazine=] |archive-url=https://web.archive.org/web/20170215115409/https://www.wired.com/2013/01/java-no-longer-a-favorite/ |archive-date=February 15, 2017 |access-date=October 15, 2023 |quote=}}</ref> | |||
The original and ] Java ]s, virtual machines, and ] were developed by Sun from 1995. As of May 2007, in compliance with the specifications of the ], Sun made available most of their Java technologies as ] under the ]. Others have also developed alternative implementations of these Sun technologies, such as the ] and ]. | |||
Java was originally developed by ] at ]. It was released in May 1995 as a core component of Sun's ]. The original and ] Java ]s, virtual machines, and ] were originally released by Sun under ]s. As of May 2007, in compliance with the specifications of the ], Sun had ] most of its Java technologies under the ] license. ] offers its own ] Java Virtual Machine, however the official ] is the ] JVM which is free open-source software and used by most developers and is the default JVM for almost all Linux distributions. | |||
== History == | |||
] | |||
{{Main|Java (Sun)#History|Java version history}} | |||
{{As of|2024|September}}, ] is the latest version (Java 22, and 20 are no longer maintained). Java 8, 11, 17, and 21 are previous LTS versions still officially supported. | |||
The Java language was created by ] in June 1991 for use in one of his many ] | |||
projects.<ref>Jon Byous, . Sun Developer Network, no date . Retrieved ], ].</ref> The language was initially called ''Oak'', after an ] that stood outside Gosling's office—and also went by the name ''Green''—and ended up later being renamed to ''Java'', from a list of random words.<ref>http://blogs.sun.com/jonathan/entry/better_is_always_different.</ref> Gosling's goals were to implement a ] and a language that had a familiar C/C++ style of notation.<ref>Heinz Kabutz, . Artima, Retrieved ], ].</ref> The first public implementation was Java 1.0 in 1995. It promised "]" (WORA), providing no-cost runtimes on popular platforms. It was fairly secure and its security was configurable, allowing network and file access to be restricted. Major web browsers soon incorporated the ability to run secure Java '']s'' within web pages. Java quickly became popular. With the advent of ''Java 2'', new versions had multiple configurations built for different types of platforms. For example, '']'' was for enterprise applications and the greatly stripped down version '']'' was for mobile applications. '']'' was the designation for the Standard Edition. In 2006, for marketing purposes, new ''J2'' versions were renamed ''Java EE'', ''Java ME'', and ''Java SE'', respectively. | |||
== History == | |||
In 1997, Sun Microsystems approached the ] and later the ] to formalize Java, but it soon withdrew from the process.<ref></ref><ref></ref><ref></ref> Java remains a ] standard that is controlled through the ].<ref></ref> At one time, Sun made most of its Java implementations available without charge although they were ]. Sun's revenue from Java was generated by the selling of licenses for specialized products such as the Java Enterprise System. Sun distinguishes between its ] and ] that is a subset of the SDK, the primary distinction being that in the JRE, the compiler, utility programs, and many necessary header files are not present. | |||
{{See also|Java (software platform)#History}} | |||
] | |||
], the creator of Java, in 2008]] | |||
], Mike Sheridan, and ] initiated the Java language project in June 1991.<ref>{{cite web |title=Java technology: The early years |last=Byous |first=Jon |date=c. 1998 |work=Sun Developer Network |publisher=] |url=https://java.sun.com/features/1998/05/birthday.html |access-date=2005-04-22 |url-status=dead |archive-url=https://web.archive.org/web/20050420081440/http://java.sun.com/features/1998/05/birthday.html |archive-date=April 20, 2005}}</ref> Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time.<ref>Object-oriented programming {{cite web |title=The History of Java Technology |date=c. 1995 |work=Sun Developer Network |url=http://www.java.com/en/javahistory/ |access-date=2010-04-30 |url-status=dead |archive-url=https://web.archive.org/web/20100210225651/http://www.java.com/en/javahistory/ |archive-date=February 10, 2010}}</ref> The language was initially called '']'' after an ] tree that stood outside Gosling's office. Later the project went by the name ''Green'' and was finally renamed ''Java'', from ], a type of coffee from ].<ref>{{cite web |last1=Murphy |first1=Kieron |date=1996-10-04 |url=https://www.infoworld.com/article/2077265/so-why-did-they-decide-to-call-it-java-.html |title=So why did they decide to call it Java? |work=] |access-date=2020-07-13 |archive-date=July 13, 2020 |archive-url=https://web.archive.org/web/20200713234202/https://www.infoworld.com/article/2077265/so-why-did-they-decide-to-call-it-java-.html |url-status=live}}</ref> Gosling designed Java with a ]/]-style syntax that system and application programmers would find familiar.<ref>Kabutz, Heinz; {{Webarchive|url=https://web.archive.org/web/20070413072630/http://www.artima.com/weblogs/viewpost.jsp?thread=7555 |date=April 13, 2007}}. Artima. Retrieved April 29, 2007.</ref> | |||
On ] ], Sun released much of Java as ] under the terms of the ] (GPL). On ] ] Sun finished the process, making all of Java's core code ], aside from a small portion of code to which Sun did not hold the copyright.<ref></ref> | |||
Sun Microsystems released the first public implementation as Java 1.0 in 1996.<ref name="oraclejavahistory">{{cite web |url=http://www.sun.com/smi/Press/sunflash/1996-01/sunflash.960123.10561.xml |archive-url=https://web.archive.org/web/20070310235103/http://www.sun.com/smi/Press/sunflash/1996-01/sunflash.960123.10561.xml |url-status=dead |archive-date=2007-03-10 |title=JAVASOFT SHIPS JAVA 1.0 |access-date=2018-05-13}}</ref> It promised ] (WORA) functionality, providing no-cost run-times on popular ]. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major ]s soon incorporated the ability to run ]s within web pages, and Java quickly became popular. The Java 1.0 compiler was re-written ] by ] to comply strictly with the Java 1.0 language specification.<ref>{{cite book |url={{Google books|rXGMFYXFDwMC|plainurl=yes}} |title=Object-oriented Programming with Java: Essentials and Applications |publisher=Tata McGraw-Hill Education |page=34}}</ref> With the advent of Java 2 (released initially as J2SE 1.2 in December 1998{{snd}} 1999), new versions had multiple configurations built for different types of platforms. ] 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 '']'', '']'', and '']'', respectively. | |||
== Philosophy == | |||
=== Primary goals === | |||
There were five primary goals in the creation of the Java language:<ref></ref> | |||
In 1997, Sun Microsystems approached the ] standards body and later the ] to formalize Java, but it soon withdrew from the process.<ref>{{cite web|url=http://www.open-std.org/JTC1/SC22/JSG/|title=JSG – Java Study Group|work=open-std.org|access-date=August 2, 2006|archive-url=https://web.archive.org/web/20060825082008/http://www.open-std.org/JTC1/SC22/JSG/|archive-date=August 25, 2006|url-status=live}}</ref><ref>{{cite web |title=Why Java Was – Not – Standardized Twice |url=http://www.computer.org/csdl/proceedings/hicss/2001/0981/05/09815015.pdf |access-date=June 3, 2018 |archive-url=https://web.archive.org/web/20140113101235/http://www.computer.org/csdl/proceedings/hicss/2001/0981/05/09815015.pdf |archive-date=January 13, 2014 |url-status=live}}</ref><ref>{{cite web |url=http://www.zdnet.com/news/what-is-ecma-and-why-microsoft-cares/298821 |title=What is ECMA—and why Microsoft cares |website=] |access-date=May 6, 2014 |archive-url=https://web.archive.org/web/20140506215226/http://www.zdnet.com/news/what-is-ecma-and-why-microsoft-cares/298821 |archive-date=May 6, 2014 |url-status=live}}</ref> Java remains a ], controlled through the ].<ref>{{cite web |url=http://www.jcp.org/en/home/index |title=Java Community Process website |publisher=Jcp.org |date=May 24, 2010 |access-date=2010-06-09 |archive-url=https://web.archive.org/web/20060808070528/http://www.jcp.org/en/home/index |archive-date=August 8, 2006 |url-status=live}}</ref> At one time, Sun made most of its Java implementations available without charge, despite their ] status. Sun generated revenue from Java through the selling of licenses for specialized products such as the Java Enterprise System. | |||
# It should use the ] methodology. | |||
# It should allow the same program to be ] on multiple ]s. | |||
# It should contain built-in support for using ]s. | |||
# It should be designed to execute code from ]s securely. | |||
# It should be easy to use by selecting what were considered the good parts of other object-oriented languages. | |||
On November 13, 2006, Sun released much of its Java virtual machine (JVM) as ] (FOSS), under the terms of the ] license. On May 8, 2007, Sun finished the process, making all of its JVM's core code available under ]/open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.<ref>{{cite web |url=http://grnlight.net/index.php/programming-articles/115-javaone-sun-the-bulk-of-java-is-open-sourced |title=JAVAONE: Sun – The bulk of Java is open sourced |publisher=GrnLight.net |access-date=2014-05-26 |archive-url=https://web.archive.org/web/20140527220942/http://grnlight.net/index.php/programming-articles/115-javaone-sun-the-bulk-of-java-is-open-sourced |archive-date=May 27, 2014 |url-status=live}}</ref> | |||
=== Platform independence === | |||
{{main|Java Platform}} | |||
Sun's vice-president Rich Green said that Sun's ideal role with regard to Java was as an ''evangelist''.<ref>{{cite web|url=http://onjava.com/pub/a/onjava/2002/04/17/evangelism.html|title=Sun's Evolving Role as Java Evangelist|publisher=]|archive-url=https://web.archive.org/web/20100915162748/http://onjava.com/pub/a/onjava/2002/04/17/evangelism.html|archive-date=September 15, 2010|url-status=live|access-date=August 2, 2009 | |||
One characteristic, ], means that ]s written in the Java language must run similarly on any supported hardware/operating-system platform. One should be able to write a program once, compile it once, and run it anywhere. | |||
}}</ref> Following ]'s acquisition of Sun Microsystems in 2009–10, Oracle has described itself as the steward of Java technology with a relentless commitment to fostering a community of participation and transparency.<ref>{{cite web |url=https://www.oracle.com/us/technologies/java/|title=Oracle and Java|work=oracle.com|publisher=Oracle Corporation |access-date=2010-08-23|quote=Oracle has been a leading and substantive supporter of Java since its emergence in 1995 and takes on the new role as steward of Java technology with a relentless commitment to fostering a community of participation and transparency. |url-status=dead|archive-url=https://web.archive.org/web/20100131091008/http://www.oracle.com/us/technologies/java/ |archive-date=January 31, 2010}}</ref> This did not prevent Oracle from filing a lawsuit against Google shortly after that for using Java inside the ] (see the '']'' section). | |||
On April 2, 2010, James Gosling resigned from ].<ref>{{cite web|url=http://nighthacks.com/roller/jag/entry/time_to_move_on |title=Time to move on... |last=Gosling |first=James |date=April 9, 2010 |work=On a New Road |access-date=2011-11-16 |author-link=James Gosling |url-status=dead |archive-url=https://web.archive.org/web/20101105031239/http://nighthacks.com/roller/jag/entry/time_to_move_on |archive-date=November 5, 2010}}</ref> | |||
This is achieved by most Java ]s by compiling the Java language code ''halfway'' (to ]) – simplified machine instructions specific to the Java platform. The code is then run on a ] (VM), a program written in native code on the host hardware that ] and executes generic Java bytecode. (In some JVM versions, bytecode can also be compiled to native code, either before or during program execution, resulting in faster execution.) Further, standardized libraries are provided to allow access to features of the host machines (such as graphics, ] and ]) in unified ways. Note that, although there is an explicit compiling stage, at some point, the Java bytecode is interpreted or converted to native ] by the ]. | |||
In January 2016, Oracle announced that Java run-time environments based on JDK 9 will discontinue the browser plugin.<ref>{{cite web|url=https://blogs.oracle.com/java-platform-group/entry/moving_to_a_plugin_free|title=Moving to a Plugin-Free Web|first=Dalibor|last=Topic|access-date=March 15, 2016|archive-url=https://web.archive.org/web/20160316164325/https://blogs.oracle.com/java-platform-group/entry/moving_to_a_plugin_free|archive-date=March 16, 2016|url-status=live}}</ref> | |||
The first implementations of the language used an interpreted virtual machine to achieve ]. These implementations produced programs that ran slower than programs compiled to native executables, for instance written in C or C++, so the language suffered a reputation for poor performance. More recent JVM implementations produce programs that run significantly faster than before, using multiple techniques. | |||
Java software runs on everything from laptops to ]s, ] to scientific ]s.<ref>{{cite web|title=Learn About Java Technology|url=http://www.java.com/en/about/|publisher=Oracle|access-date=November 21, 2011|archive-url=https://web.archive.org/web/20111124090716/http://www.java.com/en/about/|archive-date=November 24, 2011|url-status=live}}</ref> | |||
One technique, known as ''just-in-time compilation'' (JIT), translates the Java bytecode into native code at the time that the program is run, which results in a program that executes faster than interpreted code but also incurs compilation overhead during execution. More sophisticated VMs use '']'', in which the VM can analyze the behavior of the running program and selectively recompile and optimize critical parts of the program. Dynamic recompilation can achieve optimizations superior to static compilation because the dynamic compiler can base optimizations on knowledge about the runtime environment and the set of loaded classes, and can identify the ''hot spots'' (parts of the program, often inner loops, that take up the most execution time). JIT compilation and dynamic recompilation allow Java programs to take advantage of the speed of native code without losing portability. | |||
] (and others) highly recommend uninstalling outdated and unsupported versions of Java, due to unresolved security issues in older versions.<ref>{{Cite web|url=https://www.java.com/en/download/faq/remove_olderversions.xml|title=Why should I uninstall older versions of Java from my system?|publisher=Oracle|access-date=2021-09-24|archive-date=February 12, 2018|archive-url=https://web.archive.org/web/20180212011608/https://java.com/en/download/faq/remove_olderversions.xml|url-status=live}}</ref> | |||
Another technique, commonly known as ''static compilation'', is to compile directly into native code like a more traditional compiler. Static Java compilers, such as ], translate the Java language code to native ], removing the intermediate bytecode stage. This achieves good performance compared to interpretation, but at the expense of portability; the output of these compilers can only be run on a single ]. Some see avoiding the VM in this manner as defeating the point of developing in Java; however it can be useful to provide both a generic ] version, as well as an optimised native code version of an application. | |||
=== |
=== Principles === | ||
There were five primary goals in creating the Java language:<ref name="design_goals" /> | |||
<!-- these are quoted directly from the source, please do not remove or change any of them! --> | |||
# It must be simple, ], and familiar. | |||
# It must be ] and secure. | |||
# It must be architecture-neutral and portable. | |||
# It must execute with high performance. | |||
# It must be ], ], and ]. | |||
=== Versions === | |||
Sun Microsystems officially licenses the Java Standard Edition platform for ], ], and ]. Through a network of third-party vendors and licensees<ref></ref>, alternative Java environments are available for these and other platforms. To qualify as a certified Java licensee, an implementation on any particular platform must pass a rigorous suite of validation and compatibility tests. This method enables a guaranteed level of compliance and platform through a trusted set of commercial and non-commercial partners. | |||
{{Main|Java version history}} | |||
{{As of|2024|11}}, Java 8, 11, 17, and 21 are supported as ] (LTS) versions, with Java 25, releasing in September 2025, as the next scheduled LTS version.<ref>{{cite web |title=Oracle Java SE Support Roadmap |publisher=Oracle |date=September 13, 2021 |url=https://www.oracle.com/java/technologies/java-se-support-roadmap.html|access-date=September 18, 2021|archive-url=https://web.archive.org/web/20210919090451/https://www.oracle.com/java/technologies/java-se-support-roadmap.html |archive-date=2021-09-19|url-status=live}}</ref> | |||
Oracle released the last zero-cost public update for the ] version ] LTS in January 2019 for commercial use, although it will otherwise still support Java 8 with public updates for personal use indefinitely. Other vendors such as ] continue to offer free builds of OpenJDK's long-term support (LTS) versions. These builds may include additional security patches and bug fixes.<ref>{{cite web |title=Temurin™ Support; Adoptium |url=https://adoptium.net/support/ |website=adoptium.net |access-date=29 March 2024 |archive-url=https://web.archive.org/web/20240329061257/https://adoptium.net/support/ |archive-date=29 March 2024 |url-status=live}}</ref> | |||
Sun's trademark license for usage of the Java brand insists that all implementations be "compatible". This resulted in a legal dispute with ] after Sun claimed that the Microsoft implementation did not support the ] and ] interfaces and had added platform-specific features of their own. Sun sued and won both damages in 1997 (some $20 million) and a court order enforcing the terms of the license from Sun. As a result, Microsoft no longer ships Java with ], and in recent versions of Windows, ] cannot support Java applets without a third-party plugin. However, Sun and others have made available Java run-time systems at no cost for those and other versions of Windows. | |||
Major release versions of Java, along with their release dates: | |||
Platform-independent Java is essential to the ] strategy, and an even more rigorous validation is required to certify an implementation. This environment enables portable server-side applications, such as ]s, ]s, and ]s, as well as with ]s based on ], using ] environments. Through the new ] project, Sun is working to create a fully functional, unified ] implementation of the Java EE technologies. | |||
{| class="wikitable" | |||
=== Automatic memory management === | |||
! Version !! Date | |||
{{See also|Garbage collection (computer science)}} | |||
|- | |||
| JDK ] || 1995 | |||
|- | |||
| JDK 1.0 || January 23, 1996<ref>{{cite web|url=http://www.sun.com/smi/Press/sunflash/1996-01/sunflash.960123.10561.xml |title=JAVASOFT SHIPS JAVA 1.0|website=sun.com |access-date=2008-02-05 |url-status=dead |archive-url=https://web.archive.org/web/20070310235103/http://www.sun.com/smi/Press/sunflash/1996-01/sunflash.960123.10561.xml |archive-date=March 10, 2007}}</ref> | |||
|- | |||
| JDK 1.1 || February 19, 1997 | |||
|- | |||
| J2SE 1.2 || December 8, 1998 | |||
|- | |||
| J2SE 1.3 || May 8, 2000 | |||
|- | |||
| J2SE 1.4 || February 6, 2002 | |||
|- | |||
| J2SE 5.0 || September 30, 2004 | |||
|- | |||
| Java SE 6 || December 11, 2006 | |||
|- | |||
| Java SE 7 || July 28, 2011 | |||
|- | |||
| Java SE 8 (LTS) || March 18, 2014 | |||
|- | |||
| Java SE 9 || September 21, 2017 | |||
|- | |||
| Java SE 10 || March 20, 2018 | |||
|- | |||
| Java SE 11 (LTS) || September 25, 2018<ref>{{cite news|url=https://blogs.oracle.com/java-platform-group/introducing-java-se-11|title=Introducing Java SE 11|first=Sharat|last=Chander|website=oracle.com|access-date=September 26, 2018|archive-url=https://web.archive.org/web/20180926093144/https://blogs.oracle.com/java-platform-group/introducing-java-se-11|archive-date=September 26, 2018|url-status=live}}</ref> | |||
|- | |||
| Java SE 12 || March 19, 2019 | |||
|- | |||
| Java SE 13 || September 17, 2019 | |||
|- | |||
| Java SE 14 || March 17, 2020 | |||
|- | |||
| Java SE 15 || September 15, 2020<ref>{{cite news|url=https://blogs.oracle.com/java-platform-group/the-arrival-of-java-15|title=The Arrival of Java 15!|date=September 15, 2020|publisher=]|access-date=2020-09-15|archive-date=September 16, 2020|archive-url=https://web.archive.org/web/20200916092332/https://blogs.oracle.com/java-platform-group/the-arrival-of-java-15|url-status=live |last1=Chander |first1=Sharat }}</ref> | |||
|- | |||
| Java SE 16 || March 16, 2021 | |||
|- | |||
| Java SE 17 (LTS) || September 14, 2021 | |||
|- | |||
| Java SE 18 || March 22, 2022 | |||
|- | |||
| Java SE 19 || September 20, 2022 | |||
|- | |||
| Java SE 20 || March 21, 2023 | |||
|- | |||
| Java SE 21 (LTS) || September 19, 2023<ref>{{Cite web|url=https://openjdk.org/projects/jdk/21/|title=JDK 21|website=openjdk.org|access-date=September 20, 2023|archive-date=September 20, 2023|archive-url=https://web.archive.org/web/20230920173515/https://openjdk.org/projects/jdk/21/|url-status=live}}</ref> | |||
|- | |||
| Java SE 22 || March 19, 2024 | |||
|- | |||
| Java SE 23 || September 17, 2024 | |||
|} | |||
== Editions == | |||
One of the ideas behind Java's automatic memory management model is that programmers be spared the burden of having to perform manual memory management. In some languages the programmer allocates memory for the creation of objects stored on the ] and the responsibility of later deallocating that memory also resides with the programmer. If the programmer forgets to deallocate memory or writes code that fails to do so, a ] occurs and the program can consume an arbitrarily large amount of memory. Additionally, if the program attempts to deallocate the region of memory more than once, the result is undefined and the program may become unstable and may crash. Finally, in non garbage collected environments, there is a certain degree of overhead and complexity of user-code to track and finalize allocations. Often developers may box themselves into certain designs to provide reasonable assurances that memory leaks will not occur.<ref></ref> | |||
{{See also|Free Java implementations#Class library}} | |||
{{Java platforms}} | |||
Sun has defined and supports four editions of Java targeting different application environments and segmented many of its ] so that they belong to one of the platforms. The platforms are: | |||
* ] for smart-cards.<ref name="java_card">{{cite web |url=https://www.oracle.com/technetwork/java/embedded/javacard/overview/ |title=Java Card Overview |publisher=Oracle |work=Oracle Technology Network |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20150107034738/http://www.oracle.com/technetwork/java/embedded/javacard/overview/ |archive-date=January 7, 2015 |url-status=live}}</ref> | |||
* ] (Java ME) – targeting environments with limited resources.<ref name="java_me">{{cite web |url=https://www.oracle.com/technetwork/java/embedded/javame/ |title=Java Platform, Micro Edition (Java ME) |publisher=Oracle |work=Oracle Technology Network |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20150104210546/http://www.oracle.com/technetwork/java/embedded/javame/ |archive-date=January 4, 2015 |url-status=live}}</ref> | |||
* ] (Java SE) – targeting workstation environments.<ref name="java_se">{{cite web |url=https://www.oracle.com/technetwork/java/javase/overview/ |title=Java SE |publisher=Oracle |work=Oracle Technology Network |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20141224184532/http://www.oracle.com/technetwork/java/javase/overview/ |archive-date=December 24, 2014 |url-status=live}}</ref> | |||
* ] (Java EE) – targeting large distributed enterprise or Internet environments.<ref name="java_ee">{{cite web |url=https://www.oracle.com/technetwork/java/javaee/overview/ |title=Java Platform, Enterprise Edition (Java EE) |publisher=Oracle |work=Oracle Technology Network |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20141217155326/http://www.oracle.com/technetwork/java/javaee/overview/ |archive-date=December 17, 2014 |url-status=live}}</ref> | |||
The ] in the Java APIs are organized into separate groups called ]. Each package contains a set of related ], classes, subpackages and ]. | |||
In Java, this potential problem is avoided by ]. The programmer determines when objects are created, and the Java runtime is responsible for managing the ]. The program or other objects can reference an object by holding a reference to it (which, from a low-level point of view, is its address on the heap). When no references to an object remain, the ] is eligible for release by the Java garbage collector - it may be freed automatically by the garbage collector at any time. Memory leaks may still occur if a programmer's code holds a reference to an object that is no longer needed—in other words, they can still occur but at higher conceptual levels. | |||
Sun also provided an edition called ] that has been superseded by later, standards-based Java ME configuration-profile pairings. | |||
The use of garbage collection in a language can also affect programming paradigms. If, for example, the developer assumes that the cost of memory allocation/recollection is low, they may choose to more freely construct objects instead of pre-initializing, holding and reusing them. With the small cost of potential performance penalties (inner-loop construction of large/complex objects), this facilitates thread-isolation (no need to synchronize as different threads work on different object instances) and data-hiding. The use of transient immutable value-objects minimizes side-effect programming. | |||
== Execution system == | |||
Comparing Java and ], it is possible in C++ to implement similar functionality (for example, a memory management model for specific classes can be designed in C++ to improve speed and lower memory fragmentation considerably), with the possible cost of adding comparable runtime overhead to that of Java's garbage collector, and of added development time and application complexity if one favors manual implementation over using an existing third-party library. In Java, garbage collection is built-in and virtually invisible to the developer. That is, developers may have no notion of when garbage collection will take place as it may not necessarily correlate with any actions being explicitly performed by the code they write. Depending on intended application, this can be beneficial or disadvantageous: the programmer is freed from performing low-level tasks, but at the same time loses the option of writing lower level code. Additionally, the garbage collection capability demands some attention to tuning the JVM, as large heaps will cause apparently random stalls in performance. | |||
=== Java JVM and bytecode === | |||
{{Main|Java (software platform)|Java virtual machine}} | |||
<!-- we apparently have two main sections for what seems to be the same thing. Merge needed? --> | |||
One design goal of Java is ], which means that programs written for the Java platform must run similarly on any combination of hardware and operating system with adequate run time support. This is achieved by compiling the Java language code to an intermediate representation called ], instead of directly to architecture-specific ]. Java bytecode instructions are analogous to machine code, but they are intended to be executed by a ] (VM) written specifically for the host hardware. ] commonly use a ] (JRE) installed on their device for standalone Java applications or a web browser for ]s. | |||
Java does not support ] as is supported in, for example, C++. This is because the garbage collector may relocate referenced objects, invalidating such pointers. Another reason that Java forbids this is that type safety and security can no longer be guaranteed if arbitrary manipulation of pointers is allowed. | |||
Standard libraries provide a generic way to access host-specific features such as graphics, ], and ]. | |||
== Syntax == | |||
{{main|Java syntax}} | |||
The use of universal bytecode makes porting simple. However, the overhead of ] bytecode into machine instructions made interpreted programs almost always run more slowly than native ]s. ] (JIT) compilers that compile byte-codes to machine code during runtime were introduced from an early stage. Java's Hotspot compiler is actually two compilers in one; and with ] (included in e.g. Java 11, but removed as of Java 16) allowing ].<ref>{{Cite web |date=2021-08-06 |title=Deep Dive Into the New Java JIT Compiler – Graal {{!}} Baeldung |url=https://www.baeldung.com/graal-java-jit-compiler |access-date=2021-10-13 |website=www.baeldung.com |language=en-US |archive-date=October 28, 2021 |archive-url=https://web.archive.org/web/20211028165746/https://www.baeldung.com/graal-java-jit-compiler |url-status=live }}</ref> Java itself is platform-independent and is adapted to the particular platform it is to run on by a ] (JVM), which translates the ] into the platform's machine language.<ref>{{cite web|url=http://www.programmerinterview.com/index.php/java-questions/jvm-platform-dependent/|title=Is the JVM (Java Virtual Machine) platform dependent or platform independent? What is the advantage of using the JVM, and having Java be a translated language?|publisher=Programmer Interview|access-date=2015-01-19|archive-url=https://web.archive.org/web/20150119144223/http://www.programmerinterview.com/index.php/java-questions/jvm-platform-dependent/ |archive-date=January 19, 2015|url-status=live}}</ref> | |||
The syntax of Java is largely derived from ]. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built exclusively as an object oriented language. As a result, almost everything is an object and all code is written inside a class. The exceptions are the intrinsic data types (ordinal and real numbers, boolean values, and characters), which are not classes for performance reasons. | |||
=== |
==== Performance ==== | ||
{{Main|Java performance}} | |||
This is a minimal ] in Java with ]: | |||
Programs written in Java have a reputation for being slower and requiring more memory than those written in ].<ref name=Jelovic>{{cite web |title=Why Java will always be slower than C++ |last=Jelovic |first=Dejan |url=http://www.jelovic.com/articles/why_java_is_slow.htm |access-date=2008-02-15 |url-status=dead |archive-url=https://web.archive.org/web/20080211111923/http://www.jelovic.com/articles/why_java_is_slow.htm |archive-date=February 11, 2008}}</ref><ref>{{cite web |last=Hundt |first=Robert |title=Loop Recognition in C++/Java/Go/Scala |url=https://days2011.scala-lang.org/sites/days2011/files/ws3-1-Hundt.pdf |access-date=2012-07-12 |url-status=live |archive-url=https://web.archive.org/web/20111116151424/https://days2011.scala-lang.org/sites/days2011/files/ws3-1-Hundt.pdf |archive-date=November 16, 2011}}</ref> However, Java programs' execution speed improved significantly with the introduction of ] in 1997/1998 for ],<ref>{{cite web |url=http://www.symantec.com/about/news/release/article.jsp?prid=19970407_03 |title=Symantec's Just-In-Time Java Compiler To Be Integrated into Sun JDK 1.1 |access-date=August 1, 2009 |archive-url=https://web.archive.org/web/20100628171748/http://www.symantec.com/about/news/release/article.jsp?prid=19970407_03 |archive-date=June 28, 2010 |url-status=dead}}</ref> 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 ] becoming Sun's default JVM in 2000. With Java 1.5, the performance was improved with the addition of the {{code|java.util.concurrent}} package, including ] implementations of the ] and other multi-core collections, and it was improved further with Java 1.6. | |||
<source lang="java"> | |||
// Hello.java | |||
public class Hello { | |||
public static void main(String args) { | |||
System.out.println("Hello, world!"); | |||
} | |||
} | |||
</source> | |||
=== Non-JVM === | |||
To execute a Java program, the code is saved as a file named <code>Hello.java</code>. It must first be compiled into bytecode using a ], which produces a file named <code>Hello.class</code>. This class is then ''launched''. | |||
Some platforms offer direct hardware support for Java; there are micro controllers that can run Java bytecode in hardware instead of a software Java virtual machine,<ref>{{Cite journal|last1=Salcic|first1=Zoran|last2=Park|first2=Heejong|last3=Teich|first3=Jürgen|last4=Malik|first4=Avinash|last5=Nadeem|first5=Muhammad|date=2017-07-22|title=Noc-HMP: A Heterogeneous Multicore Processor for Embedded Systems Designed in SystemJ|journal=ACM Transactions on Design Automation of Electronic Systems |volume=22|issue=4|pages=73|doi=10.1145/3073416|s2cid=11150290|issn=1084-4309}}</ref> and some ]-based processors could have hardware support for executing Java bytecode through their ] option, though support has mostly been dropped in current implementations of ARM. | |||
=== Automatic memory management === | |||
The above example merits a bit of explanation. | |||
Java uses an ] to manage memory in the ]. 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 ] becomes eligible to be freed automatically by the garbage collector. Something similar to a ] may still occur if a programmer's 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.{{sfn|Bloch|2018|loc=§Item 7: Eliminate obsolete object references|p=26-28}} If methods for a non-existent object are called, a ] exception is thrown.<ref>{{cite web |url=http://docs.oracle.com/javase/8/docs/api/java/lang/NullPointerException.html |title=NullPointerException |publisher=Oracle |access-date=2014-05-06 |archive-url=https://web.archive.org/web/20140506214735/http://docs.oracle.com/javase/8/docs/api/java/lang/NullPointerException.html |archive-date=May 6, 2014 |url-status=live}}</ref><ref>{{cite web |url=http://www.artima.com/designtechniques/exceptions.html |title=Exceptions in Java |publisher=Artima.com |access-date=2010-08-10 |archive-url=https://web.archive.org/web/20090121152332/http://www.artima.com/designtechniques/exceptions.html |archive-date=January 21, 2009 |url-status=live}}</ref> | |||
* All executable statements in Java are written inside a class, including stand-alone programs. | |||
* Source files are by convention named the same as the class they contain, appending the mandatory suffix ''.java''. A <code>'''class'''</code> that is declared <code>'''public'''</code> is required to follow this convention. (In this case, the class <code>'''Hello'''</code> is public, therefore the source must be stored in a file called ''Hello.java''). | |||
* 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 was the concatenation of the name of their enclosing class, a ''$'', and an integer. | |||
* The ] <code>'''public'''</code> 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 keyword <code>'''static'''</code> indicates that the method is a ], associated with the class rather than object instances. | |||
* The keyword <code>'''void'''</code> indicates that the main method does not return any value to the caller. | |||
* The method name "<code>main</code>" 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 ] do not use or need a <code>main()</code> method. | |||
* The main method must accept an ] of '''{{Javadoc:SE|java/lang|String}}''' objects. By convention, it is referenced as <code>'''args'''</code> although any other legal identifier name can be used. Since Java 5, the main method can also use ], in the form of <code>public static void main(String... args)</code>, allowing the main method to be invoked with an arbitrary number of <code>String</code> arguments. The effect of this alternate declaration is semantically identical (the <code>args</code> parameter is still an array of <code>String</code> objects), but allows an alternate syntax for creating and passing the array. | |||
* The Java launcher launches Java by loading a given class (specified on the command line) and starting its <code>public static void main(String)</code> method. Stand-alone programs must declare this method explicitly. The <code>String args</code> parameter is an ] of {{Javadoc:SE|java/lang|String}} objects containing any arguments passed to the class. The parameters to <code>main</code> are often passed by means of a ]. | |||
* The printing facility is part of the Java standard library: The '''{{Javadoc:SE|java/lang|System}}''' class defines a public static field called '''{{Javadoc:SE|name=out|java/lang|System|out}}'''. The <code>out</code> object is an instance of the {{Javadoc:SE|java/io|PrintStream}} class and provides the method '''{{Javadoc:SE|name=println(String)|java/io|PrintStream|println(java.lang.String)}}''' for displaying data to the screen while creating a new line (]). | |||
One of the ideas behind Java's 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 ] or explicitly allocated and deallocated from the ]. In the latter case, the responsibility of managing memory resides with the programmer. If the program does not deallocate an object, a ] occurs.{{sfn|Bloch|2018|loc=§Item 7: Eliminate obsolete object references|p=26-28}} 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 ]s, but these add overhead and complexity. Garbage collection does not prevent ] leaks, i.e. those where the memory is still referenced but never used.{{sfn|Bloch|2018|loc=§Item 7: Eliminate obsolete object references|p=26-28}} | |||
=== A more comprehensive example === | |||
<source lang="java"> | |||
// OddEven.java | |||
import javax.swing.JOptionPane; | |||
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. | |||
public class OddEven { | |||
public static void main(String args) { | |||
// This is the main method. It gets called when this class is run through a Java interpreter. | |||
OddEven number = new OddEven(); | |||
/* This line of code creates a new instance of this class called "number" and | |||
* initializes it, and the next line of code calls the "showDialog()" method, | |||
* which brings up a prompt to ask you for a number | |||
*/ | |||
number.showDialog(); | |||
} | |||
private int input; // A whole number("int" means integer) | |||
// "input" is the number that the user gives to the computer | |||
public OddEven() { | |||
/* This is the constructor method. It gets called when an object of the OddEven type | |||
* is created. | |||
*/ | |||
} | |||
public void showDialog() { | |||
try | |||
/* This makes sure nothing goes wrong. If something does, | |||
* the interpreter skips to "catch" to see what it should do. | |||
*/ | |||
{ | |||
input = Integer.parseInt(JOptionPane.showInputDialog("Please Enter A Number")); | |||
calculate(); | |||
/* | |||
* The code above brings up a JOptionPane, which is a dialog box | |||
* The String returned by the "showInputDialog()" method is converted into | |||
* an integer, making the program treat it as a number instead of a word. | |||
* After that, this method calls a second method, calculate() that will | |||
* display either "Even" or "Odd." | |||
*/ | |||
} | |||
catch (NumberFormatException e) | |||
/* This means that there was a problem with the format of the number | |||
* (Like if someone were to type in 'Hello world' instead of a number). | |||
*/ | |||
{ | |||
System.err.println("ERROR: Invalid input. Please type in a numerical value."); | |||
} | |||
} | |||
public void calculate() { | |||
if (input % 2 == 0) | |||
System.out.println("Even"); | |||
/* When this gets called, it sends a message to the interpreter. | |||
* The interpreter usually shows it on the command prompt (For Windows users) | |||
* or the terminal (For Linux users).(Assuming it's open) | |||
*/ | |||
else | |||
System.out.println("Odd"); | |||
} | |||
} | |||
</source> | |||
Java does not support C/C++ style ], where object addresses can be arithmetically manipulated (e.g. by adding or subtracting an offset). This allows the garbage collector to relocate referenced objects and ensures type safety and security. | |||
* The ''']''' statement imports the '''{{Javadoc:SE|javax/swing|JOptionPane}}''' class from the '''{{Javadoc:SE|package=javax.swing|javax/swing}}''' package. | |||
* The <code>'''OddEven'''</code> class declares a single <code>''']'''</code> ] of type <code>'''int'''</code> named <code>'''input'''</code>. Every instance of the <code>OddEven</code> class has its own copy of the <code>input</code> field. The private declaration means that no other class can access (read or write) the <code>input</code> field. | |||
* <code>'''OddEven()'''</code> is a <code>'''public'''</code> ]. Constructors have the same name as the enclosing class they are declared in, and unlike a method, have no ]. A constructor is used to initialize an ] that is a newly created instance of the class. The dialog returns a <code>String</code> that is converted to an <code>int</code> by the '''{{Javadoc:SE|java/lang|Integer|parseInt(String)}}''' method. | |||
* The <code>'''calculate()'''</code> method is declared without the <code>static</code> keyword. This means that the method is invoked using a specific instance of the <code>OddEven</code> class. (The ] used to invoke the method is passed as an undeclared parameter of type <code>OddEven</code> named <code>''']'''</code>.) The method tests the expression <code>input % 2 == 0</code> using the <code>''']'''</code> keyword to see if the remainder of dividing the <code>input</code> field belonging to the instance of the class by two is zero. If this expression is true, then it prints '''Even'''; if this expression is false it prints '''Odd'''. (The <code>input</code> field can be equivalently accessed as <code>this.input</code>, which explicitly uses the undeclared <code>this</code> parameter.) | |||
* <code>'''OddEven number = new OddEven();'''</code> declares a local object ] variable in the <code>main</code> method named <code>number</code>. This variable can hold a reference to an object of type <code>OddEven</code>. The declaration initializes <code>number</code> by first creating an instance of the <code>OddEven</code> class, using the <code>''']'''</code> keyword and the <code>OddEven()</code> constructor, and then assigning this instance to the variable. | |||
* The statement <code>'''number.showDialog();'''</code> calls the calculate method. The instance of <code>OddEven</code> object referenced by the <code>number</code> ] is used to invoke the method and passed as the undeclared <code>this</code> parameter to the <code>calculate</code> method. | |||
* For simplicity, ] has been ignored in this example. Entering a value that is not a number will cause the program to crash. This can be avoided by catching and handling the {{Javadoc:SE|java/lang|NumberFormatException}} thrown by <code>Integer.parseInt(String)</code>. | |||
As in C++ and some other object-oriented languages, variables of Java's ]s are either stored directly in fields (for objects) or on the ] (for methods) rather than on the heap, as is commonly true for non-primitive data types (but see ]). This was a conscious decision by Java's designers for performance reasons. | |||
=== Applet === | |||
{{Main|Java applet}} | |||
Java contains multiple types of garbage collectors. Since Java 9, HotSpot uses the ] (G1GC) as the default.<ref>{{cite web |url=https://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance-enhancements-7.html |title=Java HotSpot™ Virtual Machine Performance Enhancements |publisher=Oracle.com |access-date=2017-04-26 |archive-url=https://web.archive.org/web/20170529071720/http://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance-enhancements-7.html |archive-date=May 29, 2017 |url-status=live}}</ref> However, there are also several other garbage collectors that can be used to manage the heap, such as the Z Garbage Collector (ZGC) introduced in Java 11, and Shenandoah GC, introduced in Java 12 but unavailable in Oracle-produced OpenJDK builds. Shenandoah is instead available in third-party builds of OpenJDK, such as ]. For most applications in Java, G1GC is sufficient. In prior versions of Java, such as Java 8, the was used as the default garbage collector. | |||
Java applets are programs that are embedded in other applications, typically in a Web page displayed in a ]. | |||
Having solved the memory management problem does not relieve the programmer of the burden of handling properly other kinds of resources, like network or database connections, file handles, etc., especially in the presence of exceptions. | |||
<source lang="java"> | |||
// Hello.java | |||
import java.applet.Applet; | |||
import java.awt.Graphics; | |||
== Syntax == | |||
public class Hello extends Applet { | |||
{{Main|Java syntax}} | |||
public void paint(Graphics gc) { | |||
].]] | |||
gc.drawString("Hello, world!", 65, 95); | |||
The syntax of Java is largely influenced by ] and ]. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language.<ref name="design_goals" /> All code is written inside classes, and every data item is an object, with the exception of the primitive data types, (i.e. integers, floating-point numbers, ], and characters), which are not objects for performance reasons. Java reuses some popular aspects of C++ (such as the {{java|printf}} method). | |||
} | |||
} | |||
</source> | |||
Unlike C++, Java does not support ]<ref name="msdn_operator_overloading">{{cite web |url=http://msdn.microsoft.com/en-us/library/ms228498%28v=vs.90%29.aspx |title=Operator Overloading (C# vs Java) |publisher=Microsoft |work=C# for Java Developers |access-date=December 10, 2014 |archive-url=https://web.archive.org/web/20150107190007/http://msdn.microsoft.com/en-us/library/ms228498(v=vs.90).aspx |archive-date=January 7, 2015 |url-status=live}}</ref> or ] for classes, though multiple inheritance is supported for ].<ref name="oracle_multiple_inheritance">{{cite web |url=https://docs.oracle.com/javase/tutorial/java/IandI/multipleinheritance.html |title=Multiple Inheritance of State, Implementation, and Type |publisher=Oracle |work=The Java Tutorials |access-date=December 10, 2014 |archive-url=https://web.archive.org/web/20141109034520/https://docs.oracle.com/javase/tutorial/java/IandI/multipleinheritance.html |archive-date=November 9, 2014 |url-status=live}}</ref> | |||
The <code>'''import'''</code> statements direct the ] to include the '''{{Javadoc:SE|package=java.applet|java/applet|Applet}}''' and '''{{Javadoc:SE|package=java.awt|java/awt|Graphics}}''' classes in the compilation. The import statement allows these classes to be referenced in the ] using the ''simple class name'' (i.e. <code>Applet</code>) instead of the ''fully qualified class name'' (i.e. <code>java.applet.Applet</code>). | |||
Java uses ] similar to those of C++. There are three different styles of comments: a single line style marked with two slashes (<code>//</code>), a multiple line style opened with <code>/*</code> and closed with <code>*/</code>, and the ] commenting style opened with <code>/**</code> and closed with <code>*/</code>. 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 ]s (IDEs) such as ] to allow developers to access documentation within the IDE. | |||
The <code>Hello</code> class <code>'''extends'''</code> (]) the <code>'''Applet'''</code> class; the <code>Applet</code> class provides the framework for the host application to display and control the ] of the applet. The <code>Applet</code> class is an ] (AWT) {{Javadoc:SE|java/awt|Component}}, which provides the applet with the capability to display a ] (GUI) and respond to user ]. | |||
=== Hello world === | |||
The <code>Hello</code> class ] the '''{{Javadoc:SE|name=paint(Graphics)|java/awt|Container|paint(java.awt.Graphics)}}''' method inherited from the {{Javadoc:SE|java/awt|Container}} ] to provide the code to display the applet. The <code>paint()</code> method is passed a <code>'''Graphics'''</code> object that contains the graphic context used to display the applet. The <code>paint()</code> method calls the graphic context '''{{Javadoc:SE|name=drawString(String, int, int)|java/awt|Graphics|drawString(java.lang.String,%20int,%20int)}}''' method to display the '''"Hello, world!"''' string at a ] offset of (<code>'''65, 95'''</code>) from the upper-left corner in the applet's display. | |||
The following is a simple example of a ] that writes a message to the ]: | |||
<syntaxhighlight lang="java" line="1">public class Example { | |||
public static void main(String args) { | |||
System.out.println("Hello World!"); | |||
} | |||
}</syntaxhighlight> | |||
== Special classes == | |||
<source lang="html4strict"> | |||
{{more citations needed|section|date=May 2019}} | |||
<!-- Hello.html --> | |||
<html> | |||
<head> | |||
<title>Hello World Applet</title> | |||
</head> | |||
<body> | |||
<applet code="Hello" width="200" height="200"> | |||
</applet> | |||
</body> | |||
</html> | |||
</source> | |||
=== Applet === | |||
An applet is placed in an ] document using the '''<code><applet></code>''' ]. The <code>applet</code> tag has three attributes set: '''<code>code="Hello"</code>''' specifies the name of the <code>Applet</code> class and '''<code>width="200" height="200"</code>''' sets the pixel width and height of the applet. Applets may also be embedded in HTML using either the <code>object</code> or <code>embed</code> element<ref></ref>, although support for these elements by Web browsers is inconsistent.<ref></ref> However, the <code>applet</code> tag is deprecated, so the <code>object</code> tag is preferred where supported. | |||
{{Main|Java applet}} | |||
Java applets are programs ] in other applications, mainly in web pages displayed in web browsers. The Java applet API was deprecated with the release of Java 9 in 2017.<ref>{{Cite web |url=https://www.oracle.com/technetwork/java/javase/9-deprecated-features-3745636.html#JDK-8074165|title=Deprecated APIs, Features, and Options| publisher=Oracle |access-date=2019-05-31|archive-date=June 19, 2019|archive-url=https://web.archive.org/web/20190619200811/https://www.oracle.com/technetwork/java/javase/9-deprecated-features-3745636.html#JDK-8074165|url-status=live}}</ref><ref>{{Cite web|title=Applet (Java Platform SE 7)|url=https://docs.oracle.com/javase/7/docs/api/java/applet/Applet.html|website=Docs |publisher=Oracle |access-date=2020-05-01 |archive-date=August 2, 2020 |archive-url=https://web.archive.org/web/20200802033524/https://docs.oracle.com/javase/7/docs/api/java/applet/Applet.html |url-status=live}}</ref> | |||
=== Servlet === | |||
The host application, typically a Web browser, instantiates the '''<code>Hello</code>''' applet and creates an {{Javadoc:SE|java/applet|AppletContext}} for the applet. Once the applet has initialized itself, it is added to the AWT display hierarchy. The <code>paint</code> method is called by the AWT ] whenever the display needs the applet to draw itself. | |||
{{Main|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 ] Java EE components that generate responses to requests from ]. Most of the time, this means generating ] pages in response to ] requests, although there are a number of other standard servlet classes available, for example for ] communication. | |||
The Java servlet API has to some extent been superseded (but still used under the hood) by two standard Java technologies for web services: | |||
=== '''Servlet''' === | |||
* the ] (JAX-RS 2.0) useful for AJAX, JSON and REST services, and | |||
{{Main|Java Servlet}} | |||
* the ] (JAX-WS) useful for ] ]s. | |||
Typical implementations of these APIs on Application Servers or Servlet Containers use a standard servlet for handling all interactions with the ] requests and responses that delegate to the web service methods for the actual business logic. | |||
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 ] Java EE components that generate responses (typically ] pages) to requests (typically ] requests) from ]s. A servlet can almost be thought of as an applet that runs on the server side—without a face. | |||
=== JavaServer Pages === | |||
<source lang="java"> | |||
// Hello.java | |||
import java.io.*; | |||
import javax.servlet.*; | |||
public class Hello extends GenericServlet { | |||
public void service(ServletRequest request, ServletResponse response) | |||
throws ServletException, IOException { | |||
response.setContentType("text/html"); | |||
final PrintWriter pw = response.getWriter(); | |||
pw.println("Hello, world!"); | |||
pw.close(); | |||
} | |||
} | |||
</source> | |||
The '''<code>import</code>''' statements direct the Java compiler to include all of the public classes and ] from the '''{{Javadoc:SE|package=java.io|java/io}}''' and '''{{Javadoc:EE|package=javax.servlet|javax/servlet}}''' ] in the compilation. | |||
The <code>'''Hello'''</code> class <code>'''extends'''</code> the '''{{Javadoc:EE|javax/servlet|GenericServlet}}''' class; the <code>GenericServlet</code> class provides the interface for the ] to forward requests to the servlet and control the servlet's lifecycle. | |||
The <code>Hello</code> class overrides the '''{{Javadoc:EE|name=service(ServletRequest, ServletResponse)|javax/servlet|Servlet|service(javax.servlet.ServletRequest,javax.servlet.ServletResponse)}}''' method defined by the {{Javadoc:EE|javax/servlet|Servlet}} ] to provide the code for the service request handler. The <code>service()</code> method is passed a '''{{Javadoc:EE|javax/servlet|ServletRequest}}''' object that contains the request from the client and a '''{{Javadoc:EE|javax/servlet|ServletResponse}}''' object used to create the response returned to the client. The <code>service()</code> method declares that it <code>'''throws'''</code> the ] {{Javadoc:EE|javax/servlet|ServletException}} and {{Javadoc:SE|java/io|IOException}} if a problem prevents it from responding to the request. | |||
The '''{{Javadoc:EE|name=setContentType(String)|javax/servlet|ServletResponse|setContentType(java.lang.String)}}''' method in the response object is called to set the ] content type of the returned data to '''"text/html"'''. The '''{{Javadoc:EE|name=getWriter()|javax/servlet|ServletResponse|getWriter()}}''' method in the response returns a '''{{Javadoc:SE|java/io|PrintWriter}}''' object that is used to write the data that is sent to the client. The '''{{Javadoc:SE|name=println(String)|java/io|PrintWriter|println(java.lang.String)}}''' method is called to write the '''"Hello, world!"''' string to the response and then the '''{{Javadoc:SE|name=close()|java/io|PrintWriter|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. | |||
=== JavaServer Page === | |||
{{Main|JavaServer Pages}} | {{Main|JavaServer Pages}} | ||
JavaServer Pages (]) are ] Java EE components that generate responses, typically ] pages, to ] requests from ]. JSPs embed Java code in an HTML page by using the special ]s <code><%</code> and <code>%></code>. 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.<ref>{{Cite web|title=What Is a JSP Page? - The Java EE 5 Tutorial|url=https://docs.oracle.com/javaee/5/tutorial/doc/bnagy.html|website=docs.oracle.com|access-date=2020-05-01|archive-date=August 2, 2020|archive-url=https://web.archive.org/web/20200802003029/https://docs.oracle.com/javaee/5/tutorial/doc/bnagy.html|url-status=live}}</ref> | |||
JavaServer Pages (JSPs) are ] Java EE components that generate responses, typically ] pages, to ] requests from ]s. JSPs embed Java code in an HTML page by using the special ]s <code lang-java"><%</code> and <code lang-java">%></code>. 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 application === | ||
{{Main|Swing (Java)}} | {{Main|Swing (Java)}} | ||
] is a graphical user interface ] for the Java SE platform. It is possible to specify a different look and feel through the ] system of Swing. Clones of ], ], and ] are supplied by Sun. ] also provides an ] look and feel for ]. 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 ] drawing routines of the underlying platforms.<ref>{{Cite web|title=Trail: Creating a GUI With JFC/Swing (The Java Tutorials)|url=https://docs.oracle.com/javase/tutorial/uiswing/|website=docs.oracle.com|access-date=2020-05-01|archive-date=April 29, 2020|archive-url=https://web.archive.org/web/20200429104302/https://docs.oracle.com/javase/tutorial/uiswing/|url-status=live}}</ref> | |||
=== JavaFX application === | |||
Swing is a graphical user interface ] for the Java SE platform. This example Swing application creates a single window with "Hello, world!" inside: | |||
{{Main|JavaFX}} | |||
] is a ] for creating and delivering ], as well as ]s that can run across a wide variety of devices. JavaFX is intended to replace ] as the standard ] (GUI) library for ], but since JDK 11 JavaFX has not been in the core JDK and instead in a separate module.<ref>{{Cite web|title=Removed from JDK 11, JavaFX 11 arrives as a standalone module |work=InfoWorld |date=September 20, 2018 |url=https://www.infoworld.com/article/3305073/removed-from-jdk-11-javafx-11-arrives-as-a-standalone-module.html|access-date=2020-10-13|archive-date=October 14, 2020|archive-url=https://web.archive.org/web/20201014141716/https://www.infoworld.com/article/3305073/removed-from-jdk-11-javafx-11-arrives-as-a-standalone-module.html|url-status=live}}</ref> JavaFX has support for ]s and ]s on ], ], and ]. JavaFX does not have support for native OS look and feels.<ref>{{Cite web|title=Getting Started with JavaFX: Hello World, JavaFX Style |work=JavaFX 2 Tutorials and Documentation|url=https://docs.oracle.com/javafx/2/get_started/hello_world.htm |publisher=Oracle |access-date=2020-05-01|archive-date= August 2, 2020 |archive-url=https://web.archive.org/web/20200802013650/https://docs.oracle.com/javafx/2/get_started/hello_world.htm|url-status=live}}</ref> | |||
<source lang="java"> | |||
// Hello.java (Java SE 5) | |||
import java.awt.BorderLayout; | |||
import javax.swing.*; | |||
public class Hello extends JFrame { | |||
public Hello() { | |||
super("hello"); | |||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |||
setLayout(new BorderLayout()); | |||
add(new JLabel("Hello, world!")); | |||
pack(); | |||
} | |||
public static void main(String args) { | |||
new Hello().setVisible(true); | |||
} | |||
} | |||
</source> | |||
The first '''<code>import</code>''' statement directs the Java compiler to include the {{Javadoc:SE|java/awt|BorderLayout}} class from the {{Javadoc:SE|package=java.awt|java/awt}} package in the compilation; the second '''<code>import</code>''' includes all of the public classes and interfaces from the '''{{Javadoc:SE|package=javax.swing|javax/swing}}''' package. | |||
=== Generics === | |||
The <code>'''Hello'''</code> class <code>'''extends'''</code> the '''{{Javadoc:SE|javax/swing|JFrame}}''' class; the <code>JFrame</code> class implements a ] with a ] and a close ]. | |||
{{Main|Generics in Java}} | |||
In 2004, ] were added to the Java language, as part of J2SE 5.0. 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 <code>Object</code>, or a different container class has to be created for each contained class. Generics allow compile-time 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 compile-time errors. If Java prevented all runtime type errors (<code>ClassCastException</code>s) from occurring, it would be ]. | |||
The <code>'''Hello()'''</code> ] initializes the frame by first calling the superclass constructor, passing the parameter <code>"hello"</code>, which is used as the window's title. It then calls the '''{{Javadoc:SE|name=setDefaultCloseOperation(int)|javax/swing|JFrame|setDefaultCloseOperation(int)}}''' method inherited from <code>JFrame</code> to set the default operation when the close control on the title bar is selected to '''{{Javadoc:SE|javax/swing|WindowConstants|EXIT_ON_CLOSE}}''' — this causes the <code>JFrame</code> to be disposed of when the frame is closed (as opposed to merely hidden), which allows the JVM to exit and the program to terminate. Next, the ] of the frame is set to a <code>BorderLayout</code>; this tells Swing how to arrange the components that will be added to the frame. A '''{{Javadoc:SE|javax/swing|JLabel}}''' is created for the string '''"Hello, world!"''' and the '''{{Javadoc:SE|name=add(Component)|java/awt|Container|add(java.awt.Component)}}''' method inherited from the {{Javadoc:SE|java/awt|Container}} superclass is called to add the label to the frame. The '''{{Javadoc:SE|name=pack()|java/awt|Window|pack()}}''' method inherited from the {{Javadoc:SE|java/awt|Window}} superclass is called to size the window and lay out its contents, in the manner indicated by the <code>BorderLayout</code>. | |||
In 2016, the type system of Java was proven ] in that it is possible to use generics to construct classes and methods that allow assignment of an instance of one class to a variable of another unrelated class. Such code is accepted by the compiler, but fails at run time with a class cast exception.<ref>{{cite web|url=https://raw.githubusercontent.com/namin/unsound/master/doc/unsound-oopsla16.pdf|title=Java and Scala's Type Systems are Unsound|access-date=February 20, 2017 |archive-url=https://web.archive.org/web/20161128174902/https://raw.githubusercontent.com/namin/unsound/master/doc/unsound-oopsla16.pdf |archive-date=November 28, 2016|url-status=live}}</ref> | |||
The <code>'''main()'''</code> method is called by the JVM when the program starts. It ] a new '''<code>Hello</code>''' frame and causes it to be displayed by calling the '''{{Javadoc:SE|name=setVisible(boolean)|java/awt|Component|setVisible(boolean)}}''' method inherited from the {{Javadoc:SE|java/awt|Component}} superclass with the boolean parameter <code>'''true'''</code>. Note that once the frame is displayed, exiting the <code>main</code> method does not cause the program to terminate because the AWT ] remains active until all of the Swing top-level windows have been disposed. | |||
== Criticism == | == Criticism == | ||
{{ |
{{Main|Criticism of Java}} | ||
Criticisms directed at Java include the implementation of generics,<ref>{{cite web | |||
|last=Arnold | |||
|first=Ken | |||
|date=June 27, 2005 | |||
|title=Generics Considered Harmful | |||
|url=https://weblogs.java.net/blog/arnold/archive/2005/06/generics_consid_1.html | |||
|publisher=java.net | |||
|access-date=September 10, 2015 | |||
|url-status=dead | |||
|archive-url=https://web.archive.org/web/20071010002142/http://weblogs.java.net/blog/arnold/archive/2005/06/generics_consid_1.html | |||
|archive-date=October 10, 2007 | |||
}}</ref> speed,<ref name=Jelovic /> the handling of unsigned numbers,<ref>{{cite web | |||
|last=Owens |first=Sean R. | |||
|url=http://darksleep.com/player/JavaAndUnsignedTypes.html | |||
|archive-url=https://web.archive.org/web/20090220171410/http://darksleep.com/player/JavaAndUnsignedTypes.html | |||
|archive-date=February 20, 2009 | |||
|title=Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof) | |||
|access-date=2011-07-04 | |||
}}</ref> the implementation of floating-point arithmetic,<ref>{{cite web | |||
|last=Kahan | |||
|first=William | |||
|date=March 1, 1998 | |||
|title=How Java's Floating-Point Hurts Everyone Everywhere – ACM 1998 Workshop on Java (Stanford) | |||
|url=http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf | |||
|publisher=Electrical Engineering & Computer Science, University of California at Berkeley | |||
|access-date=June 4, 2011 | |||
|archive-url=https://web.archive.org/web/20120905004527/http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf | |||
|archive-date=September 5, 2012 | |||
|url-status=live | |||
}}</ref> and a history of security vulnerabilities in the primary Java VM implementation ].<ref>{{cite web | |||
|url=http://blogs.technet.com/b/mmpc/archive/2010/10/18/have-you-checked-the-java.aspx | |||
|title=Have you checked the Java? | |||
|access-date=December 23, 2011 | |||
|archive-url=https://web.archive.org/web/20120921140402/http://blogs.technet.com/b/mmpc/archive/2010/10/18/have-you-checked-the-java.aspx | |||
|archive-date=September 21, 2012 | |||
|url-status=dead | |||
}}</ref> | |||
Developers have criticized the complexity and verbosity of the Java Persistence API (JPA), a standard part of Java EE. This has led to increased adoption of higher-level abstractions like Spring Data JPA, which aims to simplify database operations and reduce boilerplate code. The growing popularity of such frameworks suggests limitations in the standard JPA implementation's ease-of-use for modern Java development.<ref>{{cite book | |||
|last=Chidester | |||
|first=Ashlan | |||
|title=Java Persistence API, Jenkins and AWS | |||
|url=https://www.vlebooks.com/vleweb/product/openreader?id=none&isbn=9798224253951 | |||
|access-date=September 16, 2024 | |||
|isbn=9798224253951 | |||
}}</ref> | |||
== Class libraries == | |||
] has improved substantially since the early versions, and performance of ]s relative to native compilers has in some tests been shown to be quite similar.<ref>, J.P.Lewis and Ulrich Neumann, Computer Graphics and Immersive Technology Lab, ]</ref><ref></ref><ref>, Willie Walker, Paul Lamere, Philip Kwok</ref> The performance of the compilers does not necessarily indicate the performance of the compiled code; only careful testing can reveal the true performance issues in any system. | |||
{{Main|Java Class Library}} | |||
The ] is the ], developed to support application development in Java. It is controlled by ] in cooperation with others through the ] program.<ref>{{Citation|last=Cadenhead|first=Rogers|title=Understanding How Java Programs Work|date=2017-11-20|url=http://www.informit.com/articles/article.aspx?p=2832404&seqNum=4|access-date=2019-03-26|archive-date=August 13, 2021|archive-url=https://web.archive.org/web/20210813193850/https://www.informit.com/articles/article.aspx?p=2832404&seqNum=4|url-status=live}}</ref> Companies or individuals participating in this process can influence the design and development of the APIs. This process has been a subject of controversy during the 2010s.<ref>{{Cite news|url=https://www.theguardian.com/technology/2016/may/26/google-wins-copyright-lawsuit-oracle-java-code|title=Google wins six-year legal battle with Oracle over Android code copyright|last=Woolf|first=Nicky|date=2016-05-26|work=The Guardian|access-date=2019-03-26|language=en-GB|issn=0261-3077|archive-date=March 26, 2019|archive-url=https://web.archive.org/web/20190326203847/https://www.theguardian.com/technology/2016/may/26/google-wins-copyright-lawsuit-oracle-java-code|url-status=live}}</ref> The class library contains features such as: | |||
* The core libraries, which include: | |||
** ] (I/O or IO){{sfn|Bloch|2018|loc=§ 1 Introduction|pp=1-4}} and ] (NIO), or IO/NIO<ref>{{Cite web|url=https://docs.oracle.com/javase/8/docs/api/java/nio/package-summary.html|title=java.nio (Java Platform SE 8)|website=docs.oracle.com}}</ref> | |||
** ]<ref>{{Cite web|url=https://docs.oracle.com/javase/8/docs/technotes/guides/net/|title=Java Networking|website=docs.oracle.com}}</ref> (new ] (HTTP client) since Java 11<ref>{{Cite web|url=https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html|title=HttpClient (Java SE 11 & JDK 11)|website=docs.oracle.com}}</ref>) | |||
** ] (reflection) | |||
** ] (concurrency){{sfn|Bloch|2018|loc=§ 1 Introduction|pp=1-4}} | |||
** ] | |||
** Scripting, Compiler | |||
** ] (], streaming) | |||
** ] that implement ]s such as ], ], ], ], ] and ], or ]<ref name="collections">{{cite web |url=http://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html |title=Collections Framework Overview |publisher=Oracle |work=Java Documentation |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20141231132540/http://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html |archive-date=December 31, 2014 |url-status=live}}</ref> | |||
** ] Processing (Parsing, Transforming, Validating) libraries | |||
** ]<ref name="security">{{cite web |url=http://docs.oracle.com/javase/8/docs/technotes/guides/security/overview/jsoverview.html |title=Java Security Overview |publisher=Oracle |work=Java Documentation |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20150103045031/http://docs.oracle.com/javase/8/docs/technotes/guides/security/overview/jsoverview.html |archive-date=January 3, 2015 |url-status=live}}</ref> | |||
** ] libraries<ref name="i18n">{{cite web |url=http://docs.oracle.com/javase/tutorial/i18n/ |title=Trail: Internationalization |publisher=Oracle |work=The Java Tutorials |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20141231053232/http://docs.oracle.com/javase/tutorial/i18n/ |archive-date=December 31, 2014 |url-status=live}}</ref> | |||
* The integration libraries, which allow the application writer to communicate with external systems. These libraries include: | |||
** The ] (JDBC) ] for database access | |||
** ] (JNDI) for lookup and discovery | |||
** ] (RMI) and ] (CORBA) for distributed application development | |||
** ] (JMX) for managing and monitoring applications | |||
* ] libraries, which include: | |||
** The (heavyweight, or ]) ] (AWT), which provides ] components, the means for laying out those components and the means for handling events from those components | |||
** The (lightweight) ] libraries, which are built on AWT but provide (non-native) implementations of the AWT widgetry | |||
** APIs for audio capture, processing, and playback | |||
** ] | |||
* 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 ] to be run in web browsers | |||
* ], which allows Java applications to be efficiently distributed to ]s across the Internet | |||
* Licensing and documentation | |||
== Documentation == | |||
The default ] of ] applications written in Java using the ] toolkit is very different from native applications. It is possible to specify a different look and feel through the ] system of Swing. Clones of ], ] and ] are supplied by Sun. ] also provides an ] look and feel for ]. Though prior implementations of these looks and feels have been considered lacking,{{Fact|date=May 2008}} Swing in Java SE 6 addresses this problem by using more native ] drawing routines of the underlying platforms. Alternatively, third party toolkits such as ], ] or ] may be used for increased integration with the native windowing system. | |||
{{Main|Javadoc}} | |||
Javadoc is a comprehensive documentation system, created by ]. It provides developers with an organized system for documenting their code. Javadoc comments have an extra asterisk at the beginning, i.e. the delimiters are <code>/**</code> and <code>*/</code>, whereas the normal multi-line comments in Java are delimited by <code>/*</code> and <code>*/</code>, and single-line comments start with <code>//</code>.<ref name="javadoc_comments">{{cite web |url=https://www.oracle.com/technetwork/articles/java/index-137868.html |title=How to Write Doc Comments for the Javadoc Tool |publisher=Oracle |work=Oracle Technology Network |access-date=December 18, 2014 |archive-url=https://web.archive.org/web/20141218182906/http://www.oracle.com/technetwork/articles/java/index-137868.html |archive-date=December 18, 2014 |url-status=live}}</ref> | |||
As in C++ and some other object-oriented languages, variables of Java's ]s were not originally objects. Values of primitive types are either stored directly in fields (for objects) or on the ] (for methods) rather than on the heap, as is the common case for objects (but see ]). This was a conscious decision by Java's designers for performance reasons. Because of this, Java was not considered to be a pure object-oriented programming language. However, as of Java 5.0, ] enables programmers to write as if primitive types are their wrapper classes, with their object-oriented counterparts representing classes of their own, and freely interchange between them for improved flexibility. | |||
== Implementations == | |||
Java suppresses several features (such as ] and ]) for ''classes'' in order to simplify the language, to "save the programmers from themselves", and to prevent possible errors and anti-pattern design. This has been a source of criticism,{{Fact|date=May 2008}} relating to a lack of low-level features, but some of these limitations may be worked around. Java ''interfaces'' have always had multiple inheritance. | |||
{{See also|Free Java implementations|List of Java compilers}} | |||
{{More citations needed|section|date=September 2023}} | |||
] owns the official implementation of the Java SE platform, due to its acquisition of ] on January 27, 2010. This implementation is based on the original implementation of Java by Sun. The Oracle implementation is available for ], ], ], and ]. Because Java lacks any formal standardization recognized by ], ISO/IEC, ANSI, or other third-party standards organizations, the Oracle implementation is the ]. | |||
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 ] (JDK), which is intended for software developers and includes development tools such as the ], ], ], and a ]. Oracle has also released ], a high performance Java dynamic compiler and interpreter. | |||
== Resources == | |||
=== Java Runtime Environment === | |||
{{Main|Java Runtime Environment}} | |||
] is another 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 Java Runtime Environment, or ''JRE'', is the software required to run any ] deployed on the Java Platform. ]s commonly use a JRE in ]s and Web browser ]s. Sun also distributes a superset of the JRE called the Java 2 ] (more commonly known as the JDK), which includes development tools such as the ], ], ] and ]. | |||
The goal of Java is to make all implementations of Java compatible. Historically, Sun's trademark license for usage of the Java brand insists that all implementations be ''compatible''. This resulted in a legal dispute with ] after Sun claimed that the Microsoft implementation did not support ] (RMI) or ] (JNI) and had added platform-specific features of their own. Sun sued in 1997, and, in 2001, won a settlement of US$20 million, as well as a court order enforcing the terms of the license from Sun.<ref>{{cite news |last1=Niccolai |first1=James |date=2001-01-24 |title=Sun, Microsoft settle Java lawsuit |url=https://www.infoworld.com/article/2074908/sun-microsoft-settle-java-lawsuit.html |work=] |agency=] |access-date=2020-07-13 |archive-date=July 14, 2020 |archive-url=https://web.archive.org/web/20200714001541/https://www.infoworld.com/article/2074908/sun-microsoft-settle-java-lawsuit.html |url-status=live}}</ref> As a result, Microsoft no longer ships Java with ]. | |||
One of the unique advantages of the concept of a runtime engine is that errors (exceptions) should not 'crash' the system. Moreover, in runtime engine environments such as Java there exist tools that attach to the runtime engine and every time that an exception of interest occurs they record debugging information that existed in memory at the time the exception was thrown (stack and heap values). These ] tools provide 'root-cause' information for exceptions in Java programs that run in production, testing or development environments. | |||
Platform-independent Java is essential to ], and an even more rigorous validation is required to certify an implementation. This environment enables portable server-side applications. | |||
==== Components ==== | |||
== Use outside the Java platform == | |||
* Java ] are the compiled ]s of ] developed by the JRE implementor to support application development in Java. Examples of these libraries are: | |||
The Java programming language requires the presence of a software platform in order for compiled programs to be executed. | |||
** The core libraries, which include: | |||
*** Collection libraries that implement ]s such as ], ], ] and ] | |||
*** ] Processing (Parsing, Transforming, Validating) libraries | |||
*** Security | |||
*** ] libraries | |||
** The integration libraries, which allow the application writer to communicate with external systems. These libraries include: | |||
*** The ] (JDBC) ] for database access | |||
*** ] (JNDI) for lookup and discovery | |||
*** ] and ] for distributed application development | |||
** ] libraries, which include: | |||
*** The (heavyweight, or ]) ] (AWT), which provides ] components, the means for laying out those components and the means for handling events from those components | |||
*** The (lightweight) ] libraries, which are built on AWT but provide (non-native) implementations of the AWT widgetry | |||
*** APIs for audio capture, processing, and playback | |||
* A platform dependent implementation of ] (JVM) that is the means by which the byte codes of the Java libraries and third party applications are executed | |||
* Plugins, which enable ]s to be run in ]s | |||
* ], which allows Java applications to be efficiently distributed to ]s across the ] | |||
* Licensing and documentation | |||
Oracle supplies the ] for use with Java. The ] is an alternative software platform, used primarily for developing ]s with its own GUI system. | |||
=== APIs === | |||
{{see also|Free Java implementations#Class library}} | |||
=== Android === | |||
Sun has defined three platforms targeting different application environments and segmented many of its ]s so that they belong to one of the platforms. The platforms are: | |||
The Java language is a key pillar in ], an ] ]. Although Android, built on the ], is written largely in C, the ] uses the Java language as the basis for Android applications but does not use any of its standard GUI, SE, ME or other established Java standards.<ref>{{cite web | |||
|url=http://www.javalobby.org/nl/archive/jlnews_20071113o.html | |||
|title=Google Android: Initial Impressions and Criticism | |||
|date=November 13, 2007 | |||
|last=van Gurp | |||
|first=Jilles | |||
|work=Javalobby | |||
|quote=''Frankly, I don't understand why Google intends to ignore the vast amount of existing implementation out there. It seems like a bad case of "not invented here" to me. Ultimately, this will slow adoption. There are already too many Java platforms for the mobile world and this is yet another one'' | |||
|access-date=March 7, 2009 | |||
|archive-date=August 28, 2008 | |||
|archive-url=https://web.archive.org/web/20080828111808/http://www.javalobby.org/nl/archive/jlnews_20071113o.html | |||
|url-status=usurped | |||
}}</ref> The bytecode language supported by the Android SDK is incompatible with Java bytecode and runs on its own virtual machine, optimized for low-memory devices such as ]s and ]s. Depending on the Android version, the bytecode is either interpreted by the ] or compiled into native code by the ]. | |||
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 (]). | |||
* ] (Java ME) — targeting environments with limited resources, | |||
* ] (Java SE) — targeting workstation environments, and | |||
* ] (Java EE) — targeting large distributed enterprise or Internet environments. | |||
==== Controversy ==== | |||
The ] in the Java APIs are organized into separate groups called ]. Each package contains a set of related ]s, classes and ]. Refer to the separate platforms for a description of the packages available. | |||
{{See also|Oracle America, Inc. v. Google, Inc.}} | |||
The use of Java-related 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 Oracle's copyrights by the use of Java in Android devices.<ref>{{cite web |last=Mullin |first=Joe |title=Google guilty of infringement in Oracle trial; future legal headaches loom |url=https://arstechnica.com/tech-policy/news/2012/05/jury-rules-google-violated-copyright-law-google-moves-for-mistrial.ars |work=Law & Disorder |date=May 7, 2012 |publisher=Ars Technica |access-date=2012-05-08 |archive-url=https://web.archive.org/web/20120508134916/http://arstechnica.com/tech-policy/news/2012/05/jury-rules-google-violated-copyright-law-google-moves-for-mistrial.ars |archive-date=May 8, 2012 |url-status=live}}</ref> District Judge ] ruled on May 31, 2012, that APIs cannot be copyrighted,<ref>{{cite web | |||
The set of APIs is controlled by Sun Microsystems in cooperation with others through the ] 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. | |||
|title=Google wins crucial API ruling, Oracle's case decimated | |||
|url=https://arstechnica.com/tech/2012/05/google-wins-crucial-api-ruling-oracles-case-decimated/ | |||
|first=Joe | |||
|last=Mullin | |||
|work=Ars Technica | |||
|date=May 31, 2012 | |||
|access-date=2012-06-01 | |||
|archive-url=https://web.archive.org/web/20170312065520/https://arstechnica.com/tech-policy/2012/05/google-wins-crucial-api-ruling-oracles-case-decimated/ | |||
|archive-date=March 12, 2017 | |||
|url-status=live | |||
}}</ref> but this was reversed by the United States Court of Appeals for the Federal Circuit in May 2014.<ref name="cnet appeals">{{cite news |url=https://www.cnet.com/news/court-sides-with-oracle-over-android-in-java-patent-appeal/ |title=Court sides with Oracle over Android in Java patent appeal |work=CNET |date=May 9, 2014 |access-date=2014-05-10 |author=Rosenblatt, Seth |archive-url=https://web.archive.org/web/20140510203805/http://www.cnet.com/news/court-sides-with-oracle-over-android-in-java-patent-appeal/ |archive-date=May 10, 2014 |url-status=live}}</ref> On May 26, 2016, the district court decided in favor of Google, ruling the copyright infringement of the Java API in Android constitutes fair use.<ref>{{cite web |last1=Mullin |first1=Joe |title=Google beats Oracle—Android makes "fair use" of Java APIs |url=https://arstechnica.com/tech-policy/2016/05/google-wins-trial-against-oracle-as-jury-finds-android-is-fair-use/ |access-date=2016-05-26 |website=Ars Technica |date=2016-05-26 |archive-url=https://web.archive.org/web/20170120164551/http://arstechnica.com/tech-policy/2016/05/google-wins-trial-against-oracle-as-jury-finds-android-is-fair-use/ |archive-date=January 20, 2017 |url-status=live}}</ref> In March 2018, this ruling was overturned by the Appeals Court, which sent down the case of determining the damages to federal court in San Francisco.<ref>{{cite web | |||
|title="Google's use of the Java API packages was not fair," appeals court rules | |||
|url=https://arstechnica.com/tech-policy/2018/03/googles-use-of-the-java-api-packages-was-not-fair-appeals-court-rules/ | |||
|first=Cyrus | |||
|last=Farivar | |||
|work=Ars Technica | |||
|date=March 27, 2018 | |||
|access-date=2019-08-06 | |||
|archive-date=September 24, 2019 | |||
|archive-url=https://web.archive.org/web/20190924081919/https://arstechnica.com/tech-policy/2018/03/googles-use-of-the-java-api-packages-was-not-fair-appeals-court-rules/ | |||
|url-status=live | |||
}}</ref> | |||
Google filed a petition for ] with the ] in January 2019 to challenge the two rulings that were made by the Appeals Court in Oracle's favor.<ref>{{cite web |url=https://arstechnica.com/tech-policy/2019/01/google-asks-supreme-court-to-overrule-disastrous-ruling-on-api-copyrights/ |title=Google asks Supreme Court to overrule disastrous ruling on API copyrights |first=Timothy |last=Lee |date=April 23, 2019 |access-date=April 23, 2019 |work=] |archive-date=April 23, 2019 |archive-url=https://web.archive.org/web/20190423084450/https://arstechnica.com/tech-policy/2019/01/google-asks-supreme-court-to-overrule-disastrous-ruling-on-api-copyrights/ |url-status=live}}</ref> On April 5, 2021, the Court ruled 6–2 in Google's favor, that its use of Java APIs should be considered ]. However, the court refused to rule on the copyrightability of APIs, choosing instead to determine their ruling by considering Java's API copyrightable "purely for argument's sake."<ref>{{Cite web |url=https://www.supremecourt.gov/opinions/20pdf/18-956_d18f.pdf |title=''Google LLC v. Oracle America, Inc'' 593 U. S. ____ (2021) |access-date=April 6, 2021 |archive-date=April 5, 2021 |archive-url=https://web.archive.org/web/20210405140150/https://www.supremecourt.gov/opinions/20pdf/18-956_d18f.pdf |url-status=live}}</ref> | |||
== See also == | == See also == | ||
{{Portal|Computer programming}} | |||
* ] | |||
* ] | |||
* ], used in old Android versions, replaced by non-JIT ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | * ] | ||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
* ] | |||
== Notes == | |||
{{reflist|2}} | |||
== References == | == References == | ||
{{Reflist}} | |||
== Bibliography == | |||
{{refbegin}} | {{refbegin}} | ||
* {{cite book | title="Effective Java: Programming Language Guide" |last=Bloch| first=Joshua| publisher=Addison-Wesley | edition=third | isbn=978-0-13-468599-1| year=2018}} | |||
* Jon Byous, . Sun Developer Network, no date . Retrieved ], ]. | |||
* {{cite book |last1=Gosling |first1=James |last2=Joy |first2=Bill |last3=Steele |first3=Guy |last4=Bracha |first4=Gilad |last5=Buckley |first5=Alex |title=The Java® Language Specification |date=2014 |edition=Java SE 8 |url=https://docs.oracle.com/javase/specs/jls/se8/jls8.pdf |access-date=November 18, 2014 |archive-date=October 21, 2014 |archive-url=https://web.archive.org/web/20141021061951/http://docs.oracle.com/javase/specs/jls/se8/jls8.pdf |url-status=live}} | |||
* ], . Java.net, no date . Retrieved ], ]. | |||
* |
* {{cite book |last1=Gosling |first1=James |last2=Joy |first2=Bill |author-link2=Bill Joy |last3=Steele |first3=Guy L. Jr. |author-link3=Guy L. Steele, Jr. |first4=Gilad |last4=Bracha |author-link4=Gilad Bracha |year=2005 |title=The Java Language Specification |url=https://java.sun.com/docs/books/jls/ |edition=3rd |publisher=Addison-Wesley |isbn=0-321-24678-0 |access-date=February 8, 2019 |archive-date=February 14, 2012 |archive-url=https://web.archive.org/web/20120214061826/http://java.sun.com/docs/books/jls/ |url-status=live}} | ||
* |
* {{cite book |last1=Lindholm |first1=Tim |last2=Yellin |first2=Frank |year=1999 |title=The Java Virtual Machine Specification |url=https://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html |edition=2nd |publisher=Addison-Wesley |isbn=0-201-43294-3 |access-date=February 8, 2019 |archive-date=September 25, 2011 |archive-url=https://web.archive.org/web/20110925050249/http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html |url-status=live}} | ||
{{refend}} | {{refend}} | ||
== External links == | == External links == | ||
{{Sister project links |wikt=Java |display=Java |commons=Category:Java (programming language) |b=Java Programming |n=no |s=no |voy=no |species=no |v=Java |d=Q251}} | |||
{{Wikibooks|Java Programming}} | |||
{{wikiversity|Java Platform, Enterprise Edition/Java EE Tutorial}} | |||
{{Wikiversity|java}} | |||
* | * | ||
* | |||
* {{Javadoc:SE}} | |||
* | |||
* | |||
* | |||
* | |||
* | |||
* | |||
* (free open content documents from the ) | |||
* | |||
* | |||
{{Java ( |
{{Java (software platform)}} | ||
{{Sun Microsystems}} | {{Sun Microsystems}} | ||
{{ |
{{Oracle}} | ||
{{Oracle FOSS}} | |||
{{Programming languages}} | |||
{{Authority control}} | |||
] | ] | ||
] | |||
] | |||
] | |||
] | |||
] | ] | ||
] | ] | ||
] | ] | ||
] | |||
] | |||
] | |||
] | |||
] | |||
] | ] | ||
] | ] | ||
] | ] | ||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] |
Latest revision as of 06:14, 2 January 2025
Object-oriented programming language Not to be confused with Java (software platform), JavaScript, Java, or Javanese language. "Openframe" redirects here. For the ten-pin bowling term, see Open frame.
Paradigm | Multi-paradigm: generic, object-oriented (class-based), functional, imperative, reflective, concurrent |
---|---|
Designed by | James Gosling |
Developer | Oracle Corporation |
First appeared | May 23, 1995; 29 years ago (1995-05-23) |
Typing discipline | Static, strong, safe, nominative, manifest |
Memory management | Automatic garbage collection |
Filename extensions | .java, .class, .jar, .jmod, .war |
Website | |
Influenced by | |
CLU, Simula67, Lisp, Smalltalk, Ada 83, C++, C#, Eiffel, Mesa, Modula-3, Oberon, Objective-C, UCSD Pascal, Object Pascal | |
Influenced | |
Ada 2005, BeanShell, C#, Chapel, Clojure, ECMAScript, Fantom, Gambas, Groovy, Hack, Haxe, J#, Kotlin, PHP, Python, Scala, Seed7, Vala, JavaScript, JS++, ArkTS | |
|
Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages.
Java gained popularity shortly after its release, and has been a popular programming language since then. Java was the third most popular programming language in 2022 according to GitHub. Although still widely popular, there has been a gradual decline in use of Java in recent years with other languages using JVM gaining popularity.
Java was originally developed by James Gosling at Sun Microsystems. It was released in May 1995 as a core component of Sun's Java platform. 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 had relicensed most of its Java technologies under the GPL-2.0-only license. Oracle offers its own HotSpot Java Virtual Machine, however the official reference implementation is the OpenJDK JVM which is free open-source software and used by most developers and is the default JVM for almost all Linux distributions.
As of September 2024, Java 23 is the latest version (Java 22, and 20 are no longer maintained). Java 8, 11, 17, and 21 are previous LTS versions still officially supported.
History
See also: Java (software platform) § HistoryJames Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee, a type of coffee from Indonesia. Gosling designed Java with a C/C++-style syntax that system and application programmers would find familiar.
Sun Microsystems released the first public implementation as Java 1.0 in 1996. It promised write once, run anywhere (WORA) functionality, providing no-cost run-times on popular platforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular. The Java 1.0 compiler was re-written in Java by Arthur van Hoff to comply strictly with the Java 1.0 language specification. With the advent of Java 2 (released initially as J2SE 1.2 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 ISO/IEC JTC 1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. Java remains a de facto standard, controlled through the Java Community 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 open-source software (FOSS), under the terms of the GPL-2.0-only license. On May 8, 2007, Sun finished the process, making all of its JVM's core code available under free software/open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.
Sun's vice-president Rich Green said that Sun's ideal role with regard to Java was as an evangelist. Following Oracle Corporation's acquisition of Sun Microsystems in 2009–10, Oracle has described itself as the steward of Java technology with a relentless commitment to fostering a community of participation and transparency. This did not prevent Oracle from filing a lawsuit against Google shortly after that for using Java inside the Android SDK (see the Android section).
On April 2, 2010, James Gosling resigned from Oracle.
In January 2016, Oracle announced that Java run-time environments based on JDK 9 will discontinue the browser plugin.
Java software runs on everything from laptops to data centers, game consoles to scientific supercomputers.
Oracle (and others) highly recommend uninstalling outdated and unsupported versions of Java, due to unresolved security issues in older versions.
Principles
There were five primary goals in creating the Java language:
- It must be simple, object-oriented, and familiar.
- It must be robust and secure.
- It must be architecture-neutral and portable.
- It must execute with high performance.
- It must be interpreted, threaded, and dynamic.
Versions
Main article: Java version historyAs of November 2024, Java 8, 11, 17, and 21 are supported as long-term support (LTS) versions, with Java 25, releasing in September 2025, as the next scheduled LTS version.
Oracle released the last zero-cost public update for the legacy version Java 8 LTS in January 2019 for commercial use, although it will otherwise still support Java 8 with public updates for personal use indefinitely. Other vendors such as Adoptium continue to offer free builds of OpenJDK's long-term support (LTS) versions. These builds may include additional security patches and bug fixes.
Major release versions of Java, along with their release dates:
Version | Date |
---|---|
JDK Beta | 1995 |
JDK 1.0 | January 23, 1996 |
JDK 1.1 | February 19, 1997 |
J2SE 1.2 | December 8, 1998 |
J2SE 1.3 | May 8, 2000 |
J2SE 1.4 | February 6, 2002 |
J2SE 5.0 | September 30, 2004 |
Java SE 6 | December 11, 2006 |
Java SE 7 | July 28, 2011 |
Java SE 8 (LTS) | March 18, 2014 |
Java SE 9 | September 21, 2017 |
Java SE 10 | March 20, 2018 |
Java SE 11 (LTS) | September 25, 2018 |
Java SE 12 | March 19, 2019 |
Java SE 13 | September 17, 2019 |
Java SE 14 | March 17, 2020 |
Java SE 15 | September 15, 2020 |
Java SE 16 | March 16, 2021 |
Java SE 17 (LTS) | September 14, 2021 |
Java SE 18 | March 22, 2022 |
Java SE 19 | September 20, 2022 |
Java SE 20 | March 21, 2023 |
Java SE 21 (LTS) | September 19, 2023 |
Java SE 22 | March 19, 2024 |
Java SE 23 | September 17, 2024 |
Editions
See also: Free Java implementations § Class libraryJava platform editions |
---|
|
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 smart-cards.
- 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, subpackages and exceptions.
Sun also provided an edition called Personal Java that has been superseded by later, standards-based Java ME configuration-profile pairings.
Execution system
Java JVM and bytecode
Main articles: Java (software platform) and Java virtual machineOne 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 run time support. This is achieved by compiling the Java language code to an intermediate representation called Java bytecode, instead of directly to architecture-specific 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 device for standalone Java applications or a web browser for Java applets.
Standard libraries provide a generic way to access host-specific 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. Just-in-time (JIT) compilers that compile byte-codes to machine code during runtime were introduced from an early stage. Java's Hotspot compiler is actually two compilers in one; and with GraalVM (included in e.g. Java 11, but removed as of Java 16) allowing tiered compilation. Java itself is platform-independent and is adapted to the particular platform it is to run on by a Java virtual machine (JVM), which translates the Java bytecode into the platform's machine language.
Performance
Main article: Java performancePrograms written in Java have a reputation for being slower and requiring more memory than those written in C++. However, Java programs' execution speed improved significantly with the introduction of just-in-time compilation in 1997/1998 for Java 1.1, 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 Sun's default JVM in 2000. With Java 1.5, the performance was improved with the addition of the java.util.concurrent
package, including lock-free implementations of the ConcurrentMaps and other multi-core collections, and it was improved further with Java 1.6.
Non-JVM
Some platforms offer direct hardware support for Java; there are micro controllers 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 programmer's 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 non-existent object are called, a null pointer exception is thrown.
One of the ideas behind Java's 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. Garbage collection does not prevent logical memory leaks, i.e. 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 C/C++ style pointer arithmetic, where object addresses can be arithmetically manipulated (e.g. by adding or subtracting an offset). This allows the garbage collector to relocate referenced objects and ensures type safety and security.
As in C++ and some other object-oriented languages, variables of Java's 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 non-primitive data types (but see escape analysis). This was a conscious decision by Java's designers for performance reasons.
Java contains multiple types of garbage collectors. Since Java 9, HotSpot uses the Garbage First Garbage Collector (G1GC) as the default. However, there are also several other garbage collectors that can be used to manage the heap, such as the Z Garbage Collector (ZGC) introduced in Java 11, and Shenandoah GC, introduced in Java 12 but unavailable in Oracle-produced OpenJDK builds. Shenandoah is instead available in third-party builds of OpenJDK, such as Eclipse Temurin. For most applications in Java, G1GC is sufficient. In prior versions of Java, such as Java 8, the Parallel Garbage Collector was used as the default garbage collector.
Having solved the memory management problem does not relieve the programmer of the burden of handling properly other kinds of resources, like network or database connections, file handles, etc., especially in the presence of exceptions.
Syntax
Main article: Java syntaxThe syntax of Java is largely influenced by C++ and C. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language. All code is written inside classes, and every data item is an object, with the exception of the primitive data types, (i.e. integers, floating-point 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 or multiple inheritance for classes, though multiple inheritance is supported for interfaces.
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
The following is a simple example of a "Hello, World!" program that writes a message to the standard output:
public class Example { public static void main(String args) { System.out.println("Hello World!"); } }
Special classes
This section needs additional citations for verification. Please help improve this article by adding citations to reliable sources in this section. Unsourced material may be challenged and removed. Find sources: "Java" programming language – news · newspapers · books · scholar · JSTOR (May 2019) (Learn how and when to remove this message) |
Applet
Main article: Java appletJava applets are programs embedded in other applications, mainly in web pages displayed in web browsers. The Java applet API was deprecated with the release of Java 9 in 2017.
Servlet
Main article: Java servletJava 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 server-side Java EE components that generate responses to requests from clients. Most of the time, this means generating HTML pages in response to HTTP requests, although there are a number of other standard servlet classes available, for example for WebSocket communication.
The Java servlet API has to some extent been superseded (but still used under the hood) by two standard Java technologies for web services:
- the Java API for RESTful Web Services (JAX-RS 2.0) useful for AJAX, JSON and REST services, and
- the Java API for XML Web Services (JAX-WS) useful for SOAP Web Services.
Typical implementations of these APIs on Application Servers or Servlet Containers use a standard servlet for handling all interactions with the HTTP requests and responses that delegate to the web service methods for the actual business logic.
JavaServer Pages
Main article: JavaServer PagesJavaServer Pages (JSP) are server-side 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
Main article: 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.
JavaFX application
Main article: JavaFXJavaFX is a software platform for creating and delivering desktop applications, as well as rich web applications that can run across a wide variety of devices. JavaFX is intended to replace Swing as the standard graphical user interface (GUI) library for Java SE, but since JDK 11 JavaFX has not been in the core JDK and instead in a separate module. JavaFX has support for desktop computers and web browsers on Microsoft Windows, Linux, and macOS. JavaFX does not have support for native OS look and feels.
Generics
Main article: Generics in JavaIn 2004, generics were added to the Java language, as part of J2SE 5.0. 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 compile-time 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 compile-time errors. If Java prevented all runtime type errors (ClassCastException
s) from occurring, it would be type safe.
In 2016, the type system of Java was proven unsound in that it is possible to use generics to construct classes and methods that allow assignment of an instance of one class to a variable of another unrelated class. Such code is accepted by the compiler, but fails at run time with a class cast exception.
Criticism
Main article: Criticism of JavaCriticisms directed at Java include the implementation of generics, speed, the handling of unsigned numbers, the implementation of floating-point arithmetic, and a history of security vulnerabilities in the primary Java VM implementation HotSpot. Developers have criticized the complexity and verbosity of the Java Persistence API (JPA), a standard part of Java EE. This has led to increased adoption of higher-level abstractions like Spring Data JPA, which aims to simplify database operations and reduce boilerplate code. The growing popularity of such frameworks suggests limitations in the standard JPA implementation's ease-of-use for modern Java development.
Class libraries
Main article: Java Class LibraryThe Java Class Library is the standard library, developed to support application development in Java. It is controlled by Oracle 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 during the 2010s. The class library contains features such as:
- The core libraries, which include:
- Input/output (I/O or IO) and non-blocking I/O (NIO), or IO/NIO
- Networking (new user agent (HTTP client) since Java 11)
- Reflective programming (reflection)
- Concurrent computing (concurrency)
- Generics
- Scripting, Compiler
- Functional programming (Lambda, streaming)
- Collection libraries that implement data structures such as lists, dictionaries, trees, sets, queues and double-ended 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
- Java remote method invocation (RMI) and Common Object Request Broker Architecture (CORBA) for distributed application development
- Java Management Extensions (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 (non-native) 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
Main article: JavadocJavadoc is a comprehensive documentation system, created by Sun Microsystems. It provides developers with an organized system for documenting their code. Javadoc comments have an extra asterisk at the beginning, i.e. the delimiters are /**
and */
, whereas the normal multi-line comments in Java are delimited by /*
and */
, and single-line comments start with //
.
Implementations
See also: Free Java implementations and List of Java compilersThis section needs additional citations for verification. Please help improve this article by adding citations to reliable sources in this section. Unsourced material may be challenged and removed. Find sources: "Java" programming language – news · newspapers · books · scholar · JSTOR (September 2023) (Learn how and when to remove this message) |
Oracle Corporation owns the official implementation of the Java SE platform, due to its 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 Windows, macOS, Linux, and Solaris. Because Java lacks any formal standardization recognized by Ecma International, ISO/IEC, ANSI, or other third-party standards organizations, 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. Oracle has also released GraalVM, a high performance Java dynamic compiler and interpreter.
OpenJDK is another 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, Sun's 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 Java remote method invocation (RMI) or Java Native Interface (JNI) and had added platform-specific features of their own. Sun sued in 1997, and, in 2001, won a settlement of US$20 million, as well as a court order enforcing the terms of the license from Sun. As a result, Microsoft no longer ships Java with Windows.
Platform-independent Java is essential to Java EE, and an even more rigorous validation is required to certify an implementation. This environment enables portable server-side 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.
Android
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 but does not use any of its standard GUI, SE, ME or other established Java standards. The bytecode language supported by the Android SDK is incompatible with Java bytecode and runs on its own virtual machine, optimized for low-memory 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 Java-related 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 Oracle's copyrights by the use of Java in Android devices. District Judge William Alsup ruled on May 31, 2012, that APIs cannot be copyrighted, but this was reversed by the United States Court of Appeals for the Federal Circuit in May 2014. On May 26, 2016, the district court decided in favor of Google, ruling the copyright infringement of the Java API in Android constitutes fair use. In March 2018, this ruling was overturned by the Appeals Court, which sent down the case of determining the damages to federal court in San Francisco. Google filed a petition for writ of certiorari with the Supreme Court of the United States in January 2019 to challenge the two rulings that were made by the Appeals Court in Oracle's favor. On April 5, 2021, the Court ruled 6–2 in Google's favor, that its use of Java APIs should be considered fair use. However, the court refused to rule on the copyrightability of APIs, choosing instead to determine their ruling by considering Java's API copyrightable "purely for argument's sake."
See also
- C#
- C++
- Dalvik, used in old Android versions, replaced by non-JIT Android Runtime
- Java Heterogeneous Distributed Computing
- List of Java APIs
- List of Java frameworks
- List of JVM languages
- List of Java virtual machines
- Comparison of C# and Java
- Comparison of Java and C++
- Comparison of programming languages
References
- Binstock, Andrew (May 20, 2015). "Java's 20 Years of Innovation". Forbes. Archived from the original on March 14, 2016. Retrieved March 18, 2016.
- ^ Barbara Liskov with John Guttag (2000). Program Development in Java – Abstraction, Specification, and Object-Oriented Design. USA, Addison Wesley. ISBN 978-0-201-65768-5.
- Chaudhary, Harry H. (July 28, 2014). "Cracking The Java Programming Interview :: 2000+ Java Interview Que/Ans". Archived from the original on September 29, 2023. Retrieved May 29, 2016.
- Java 5.0 added several new language features (the enhanced for loop, autoboxing, varargs and annotations), after they were introduced in the similar (and competing) C# language. Archived March 19, 2011, at the Wayback Machine Archived January 7, 2006, at the Wayback Machine
- Gosling, James; McGilton, Henry (May 1996). "The Java Language Environment". Archived from the original on May 6, 2014. Retrieved May 6, 2014.
- Gosling, James; Joy, Bill; Steele, Guy; Bracha, Gilad. "The Java Language Specification, 2nd Edition". Archived from the original on August 5, 2011. Retrieved February 8, 2008.
- "The A-Z of Programming Languages: Modula-3". Computerworld. Archived from the original on January 5, 2009. Retrieved June 9, 2010.
- Niklaus Wirth stated on a number of public occasions, e.g. in a lecture at the Polytechnic Museum, Moscow in September 2005 (several independent first-hand accounts in Russian exist, e.g. one with an audio recording: Filippova, Elena (September 22, 2005). "Niklaus Wirth's lecture at the Polytechnic Museum in Moscow". Archived from the original on December 1, 2020. Retrieved November 20, 2011.), that the Sun Java design team licensed the Oberon compiler sources a number of years prior to the release of Java and examined it: a (relative) compactness, type safety, garbage collection, no multiple inheritance for classes – all these key overall design features are shared by Java and Oberon.
- Patrick Naughton cites Objective-C as a strong influence on the design of the Java programming language, stating that notable direct derivatives include Java interfaces (derived from Objective-C's protocol) and primitive wrapper classes. Archived July 13, 2011, at the Wayback Machine
- TechMetrix Research (1999). "History of Java" (PDF). Java Application Servers Report. Archived from the original (PDF) on December 29, 2010.
The project went ahead under the name green and the language was based on an old model of UCSD Pascal, which makes it possible to generate interpretive code.
- "A Conversation with James Gosling – ACM Queue". Queue.acm.org. August 31, 2004. Archived from the original on July 16, 2015. Retrieved June 9, 2010.
- The Java Language Team. About Microsoft's "Delegates" (White Paper). JavaSoft, Sun Microsystems, Inc. Archived from the original on June 27, 2012.
In the summer of 1996, Sun was designing the precursor to what is now the event model of the AWT and the JavaBeans component architecture. Borland contributed greatly to this process. We looked very carefully at Delphi Object Pascal and built a working prototype of bound method references in order to understand their interaction with the Java programming language and its APIs.
- "Chapel spec (Acknowledgements)" (PDF). Cray Inc. October 1, 2015. Archived (PDF) from the original on February 5, 2016. Retrieved January 14, 2016.
- "Gambas Documentation Introduction". Gambas Website. Archived from the original on October 9, 2017. Retrieved October 9, 2017.
- "Facebook Q&A: Hack brings static typing to PHP world". InfoWorld. March 26, 2014. Archived from the original on February 13, 2015. Retrieved January 11, 2015.
- "Write once, run anywhere?". Computer Weekly. May 2, 2002. Archived from the original on August 13, 2021. Retrieved July 27, 2009.
- ^ "1.2 Design Goals of the Java Programming Language". Oracle. January 1, 1999. Archived from the original on January 23, 2013. Retrieved January 14, 2013.
- Melanson, Mike (August 9, 2022). "Don't call it a comeback: Why Java is still champ". GitHub. Archived from the original on August 25, 2023. Retrieved October 15, 2023.
- "The top programming languages". The State of the Octoverse. GitHub. Archived from the original on August 2, 2023. Retrieved October 15, 2023.
- McMillan, Robert (August 1, 2013). "Is Java Losing Its Mojo?". Wired. Archived from the original on February 15, 2017. Retrieved October 15, 2023.
- Byous, Jon (c. 1998). "Java technology: The early years". Sun Developer Network. Sun Microsystems. Archived from the original on April 20, 2005. Retrieved April 22, 2005.
- Object-oriented programming "The History of Java Technology". Sun Developer Network. c. 1995. Archived from the original on February 10, 2010. Retrieved April 30, 2010.
- Murphy, Kieron (October 4, 1996). "So why did they decide to call it Java?". JavaWorld. Archived from the original on July 13, 2020. Retrieved July 13, 2020.
- Kabutz, Heinz; Once Upon an Oak Archived April 13, 2007, at the Wayback Machine. Artima. Retrieved April 29, 2007.
- "JAVASOFT SHIPS JAVA 1.0". Archived from the original on March 10, 2007. Retrieved May 13, 2018.
- Object-oriented Programming with Java: Essentials and Applications. Tata McGraw-Hill Education. p. 34.
- "JSG – Java Study Group". open-std.org. Archived from the original on August 25, 2006. Retrieved August 2, 2006.
- "Why Java Was – Not – Standardized Twice" (PDF). Archived (PDF) from the original on January 13, 2014. Retrieved June 3, 2018.
- "What is ECMA—and why Microsoft cares". ZDNet. Archived from the original on May 6, 2014. Retrieved May 6, 2014.
- "Java Community Process website". Jcp.org. May 24, 2010. Archived from the original on August 8, 2006. Retrieved June 9, 2010.
- "JAVAONE: Sun – The bulk of Java is open sourced". GrnLight.net. Archived from the original on May 27, 2014. Retrieved May 26, 2014.
- "Sun's Evolving Role as Java Evangelist". O'Reilly Media. Archived from the original on September 15, 2010. Retrieved August 2, 2009.
- "Oracle and Java". oracle.com. Oracle Corporation. Archived from the original on January 31, 2010. Retrieved August 23, 2010.
Oracle has been a leading and substantive supporter of Java since its emergence in 1995 and takes on the new role as steward of Java technology with a relentless commitment to fostering a community of participation and transparency.
- Gosling, James (April 9, 2010). "Time to move on..." On a New Road. Archived from the original on November 5, 2010. Retrieved November 16, 2011.
- Topic, Dalibor. "Moving to a Plugin-Free Web". Archived from the original on March 16, 2016. Retrieved March 15, 2016.
- "Learn About Java Technology". Oracle. Archived from the original on November 24, 2011. Retrieved November 21, 2011.
- "Why should I uninstall older versions of Java from my system?". Oracle. Archived from the original on February 12, 2018. Retrieved September 24, 2021.
- "Oracle Java SE Support Roadmap". Oracle. September 13, 2021. Archived from the original on September 19, 2021. Retrieved September 18, 2021.
- "Temurin™ Support; Adoptium". adoptium.net. Archived from the original on March 29, 2024. Retrieved March 29, 2024.
- "JAVASOFT SHIPS JAVA 1.0". sun.com. Archived from the original on March 10, 2007. Retrieved February 5, 2008.
- Chander, Sharat. "Introducing Java SE 11". oracle.com. Archived from the original on September 26, 2018. Retrieved September 26, 2018.
- Chander, Sharat (September 15, 2020). "The Arrival of Java 15!". Oracle. Archived from the original on September 16, 2020. Retrieved September 15, 2020.
- "JDK 21". openjdk.org. Archived from the original on September 20, 2023. Retrieved September 20, 2023.
- "Java Card Overview". Oracle Technology Network. Oracle. Archived from the original on January 7, 2015. Retrieved December 18, 2014.
- "Java Platform, Micro Edition (Java ME)". Oracle Technology Network. Oracle. Archived from the original on January 4, 2015. Retrieved December 18, 2014.
- "Java SE". Oracle Technology Network. Oracle. Archived from the original on December 24, 2014. Retrieved December 18, 2014.
- "Java Platform, Enterprise Edition (Java EE)". Oracle Technology Network. Oracle. Archived from the original on December 17, 2014. Retrieved December 18, 2014.
- "Deep Dive Into the New Java JIT Compiler – Graal | Baeldung". www.baeldung.com. August 6, 2021. Archived from the original on October 28, 2021. Retrieved October 13, 2021.
- "Is the JVM (Java Virtual Machine) platform dependent or platform independent? What is the advantage of using the JVM, and having Java be a translated language?". Programmer Interview. Archived from the original on January 19, 2015. Retrieved January 19, 2015.
- ^ Jelovic, Dejan. "Why Java will always be slower than C++". Archived from the original on February 11, 2008. Retrieved February 15, 2008.
- Hundt, Robert. "Loop Recognition in C++/Java/Go/Scala" (PDF). Archived (PDF) from the original on November 16, 2011. Retrieved July 12, 2012.
- "Symantec's Just-In-Time Java Compiler To Be Integrated into Sun JDK 1.1". Archived from the original on June 28, 2010. Retrieved August 1, 2009.
- Salcic, Zoran; Park, Heejong; Teich, Jürgen; Malik, Avinash; Nadeem, Muhammad (July 22, 2017). "Noc-HMP: A Heterogeneous Multicore Processor for Embedded Systems Designed in SystemJ". ACM Transactions on Design Automation of Electronic Systems. 22 (4): 73. doi:10.1145/3073416. ISSN 1084-4309. S2CID 11150290.
- ^ Bloch 2018, p. 26-28, §Item 7: Eliminate obsolete object references.
- "NullPointerException". Oracle. Archived from the original on May 6, 2014. Retrieved May 6, 2014.
- "Exceptions in Java". Artima.com. Archived from the original on January 21, 2009. Retrieved August 10, 2010.
- "Java HotSpot™ Virtual Machine Performance Enhancements". Oracle.com. Archived from the original on May 29, 2017. Retrieved April 26, 2017.
- "Operator Overloading (C# vs Java)". C# for Java Developers. Microsoft. Archived from the original on January 7, 2015. Retrieved December 10, 2014.
- "Multiple Inheritance of State, Implementation, and Type". The Java Tutorials. Oracle. Archived from the original on November 9, 2014. Retrieved December 10, 2014.
- "Deprecated APIs, Features, and Options". Oracle. Archived from the original on June 19, 2019. Retrieved May 31, 2019.
- "Applet (Java Platform SE 7)". Docs. Oracle. Archived from the original on August 2, 2020. Retrieved May 1, 2020.
- "What Is a JSP Page? - The Java EE 5 Tutorial". docs.oracle.com. Archived from the original on August 2, 2020. Retrieved May 1, 2020.
- "Trail: Creating a GUI With JFC/Swing (The Java Tutorials)". docs.oracle.com. Archived from the original on April 29, 2020. Retrieved May 1, 2020.
- "Removed from JDK 11, JavaFX 11 arrives as a standalone module". InfoWorld. September 20, 2018. Archived from the original on October 14, 2020. Retrieved October 13, 2020.
- "Getting Started with JavaFX: Hello World, JavaFX Style". JavaFX 2 Tutorials and Documentation. Oracle. Archived from the original on August 2, 2020. Retrieved May 1, 2020.
- "Java and Scala's Type Systems are Unsound" (PDF). Archived (PDF) from the original on November 28, 2016. Retrieved February 20, 2017.
- Arnold, Ken (June 27, 2005). "Generics Considered Harmful". java.net. Archived from the original on October 10, 2007. Retrieved September 10, 2015.
- Owens, Sean R. "Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof)". Archived from the original on February 20, 2009. Retrieved July 4, 2011.
- Kahan, William (March 1, 1998). "How Java's Floating-Point Hurts Everyone Everywhere – ACM 1998 Workshop on Java (Stanford)" (PDF). Electrical Engineering & Computer Science, University of California at Berkeley. Archived (PDF) from the original on September 5, 2012. Retrieved June 4, 2011.
- "Have you checked the Java?". Archived from the original on September 21, 2012. Retrieved December 23, 2011.
- Chidester, Ashlan. Java Persistence API, Jenkins and AWS. ISBN 9798224253951. Retrieved September 16, 2024.
- Cadenhead, Rogers (November 20, 2017), Understanding How Java Programs Work, archived from the original on August 13, 2021, retrieved March 26, 2019
- Woolf, Nicky (May 26, 2016). "Google wins six-year legal battle with Oracle over Android code copyright". The Guardian. ISSN 0261-3077. Archived from the original on March 26, 2019. Retrieved March 26, 2019.
- ^ Bloch 2018, pp. 1–4, § 1 Introduction.
- "java.nio (Java Platform SE 8)". docs.oracle.com.
- "Java Networking". docs.oracle.com.
- "HttpClient (Java SE 11 & JDK 11)". docs.oracle.com.
- "Collections Framework Overview". Java Documentation. Oracle. Archived from the original on December 31, 2014. Retrieved December 18, 2014.
- "Java Security Overview". Java Documentation. Oracle. Archived from the original on January 3, 2015. Retrieved December 18, 2014.
- "Trail: Internationalization". The Java Tutorials. Oracle. Archived from the original on December 31, 2014. Retrieved December 18, 2014.
- "How to Write Doc Comments for the Javadoc Tool". Oracle Technology Network. Oracle. Archived from the original on December 18, 2014. Retrieved December 18, 2014.
- Niccolai, James (January 24, 2001). "Sun, Microsoft settle Java lawsuit". JavaWorld. IDG News Service. Archived from the original on July 14, 2020. Retrieved July 13, 2020.
- van Gurp, Jilles (November 13, 2007). "Google Android: Initial Impressions and Criticism". Javalobby. Archived from the original on August 28, 2008. Retrieved March 7, 2009.
Frankly, I don't understand why Google intends to ignore the vast amount of existing implementation out there. It seems like a bad case of "not invented here" to me. Ultimately, this will slow adoption. There are already too many Java platforms for the mobile world and this is yet another one
- Mullin, Joe (May 7, 2012). "Google guilty of infringement in Oracle trial; future legal headaches loom". Law & Disorder. Ars Technica. Archived from the original on May 8, 2012. Retrieved May 8, 2012.
- Mullin, Joe (May 31, 2012). "Google wins crucial API ruling, Oracle's case decimated". Ars Technica. Archived from the original on March 12, 2017. Retrieved June 1, 2012.
- Rosenblatt, Seth (May 9, 2014). "Court sides with Oracle over Android in Java patent appeal". CNET. Archived from the original on May 10, 2014. Retrieved May 10, 2014.
- Mullin, Joe (May 26, 2016). "Google beats Oracle—Android makes "fair use" of Java APIs". Ars Technica. Archived from the original on January 20, 2017. Retrieved May 26, 2016.
- Farivar, Cyrus (March 27, 2018). ""Google's use of the Java API packages was not fair," appeals court rules". Ars Technica. Archived from the original on September 24, 2019. Retrieved August 6, 2019.
- Lee, Timothy (April 23, 2019). "Google asks Supreme Court to overrule disastrous ruling on API copyrights". Ars Technica. Archived from the original on April 23, 2019. Retrieved April 23, 2019.
- "Google LLC v. Oracle America, Inc 593 U. S. ____ (2021)" (PDF). Archived (PDF) from the original on April 5, 2021. Retrieved April 6, 2021.
Bibliography
- Bloch, Joshua (2018). "Effective Java: Programming Language Guide" (third ed.). Addison-Wesley. ISBN 978-0-13-468599-1.
- Gosling, James; Joy, Bill; Steele, Guy; Bracha, Gilad; Buckley, Alex (2014). The Java® Language Specification (PDF) (Java SE 8 ed.). Archived (PDF) from the original on October 21, 2014. Retrieved November 18, 2014.
- Gosling, James; Joy, Bill; Steele, Guy L. Jr.; Bracha, Gilad (2005). The Java Language Specification (3rd ed.). Addison-Wesley. ISBN 0-321-24678-0. Archived from the original on February 14, 2012. Retrieved February 8, 2019.
- Lindholm, Tim; Yellin, Frank (1999). The Java Virtual Machine Specification (2nd ed.). Addison-Wesley. ISBN 0-201-43294-3. Archived from the original on September 25, 2011. Retrieved February 8, 2019.
External links
Java (software platform) | |||||||
---|---|---|---|---|---|---|---|
Platforms |
| ||||||
Oracle technologies | |||||||
Platform technologies | |||||||
Major third-party technologies | |||||||
History | |||||||
JVM languages | |||||||
Community |
| ||||||
Category Computer programming portal |
Sun Microsystems | ||||||||
---|---|---|---|---|---|---|---|---|
Acquired by Oracle | ||||||||
Hardware |
| |||||||
Software | ||||||||
Storage | ||||||||
Performance | ||||||||
Research | ||||||||
Education | ||||||||
Community |
| |||||||
Acquisitions | ||||||||
Slogans | ||||||||
Category |
Oracle Corporation | |
---|---|
Corporate directors | |
Acquisitions (list) | |
Databases | |
Programming languages | |
IDEs | |
Middleware | |
Operating systems | |
Computer hardware | |
Computer appliances | |
Education and recognition | |
Oracle free and open-source software (FOSS) | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Software |
| ||||||||||||
Related |
Programming languages | |
---|---|
- Java (programming language)
- C programming language family
- Class-based programming languages
- Concurrent programming languages
- Java platform
- Java specification requests
- JVM programming languages
- Multi-paradigm programming languages
- Object-oriented programming languages
- Programming languages created in 1995
- Programming languages
- Statically typed programming languages
- Sun Microsystems
- Compiled programming languages
- American inventions