- Java Class Library Explained
- Implementation and configuration
- Conformance
- Main features
- Licensing
- Prior licenses
- Open source release
- Alternative implementations
- See also
- External links
- Notes and References
- Стандартная библиотека классов Java
- Структура, компиляция и выполнение Java-программы
- Структура, компиляция и выполнение Java-программы .
Java Class Library Explained
The Java Class Library (JCL) is a set of dynamically loadable libraries that Java Virtual Machine (JVM) languages can call at run time. Because the Java Platform is not dependent on a specific operating system, applications cannot rely on any of the platform-native libraries. Instead, the Java Platform provides a comprehensive set of standard class libraries, containing the functions common to modern operating systems.
JCL serves three purposes within the JVM:
- Like other standard code libraries, they provide the programmer a well-known set of useful facilities, such as container classes and regular expression processing.
- The library provides an abstract interface to tasks that would normally depend heavily on the hardware and operating system, such as network access and file access.
- Some underlying platforms may not support all of the features a Java application expects. In these cases, the library implementation can either emulate those features or provide a consistent way to check for the presence of a specific feature.
Implementation and configuration
JCL is almost entirely written in Java, except for the parts that need direct access to the hardware and operating system (such as for I/O or bitmap graphics). The classes that give access to these functions commonly use Java Native Interface wrappers to access operating system APIs.
Almost all of JCL is stored in a single Java archive file called «rt.jar» which is provided with JRE and JDK distributions. The Java Class Library (rt.jar) is located in the default bootstrap classpath [1] and does not have to appear in the classpath declared for the application. The runtime uses the bootstrap class loader to find the JCL.
The Java Module System (part of the Java 9 release) broke the monolithic «rt.jar» JAR file and modularized the JCL itself in several modules with specified dependencies. [2]
Conformance
Any Java implementation must pass the Java Technology Compatibility Kit tests for compliance, which includes JCL tests.
Main features
See main article: Java Platform, Standard Edition. JCL Features are accessed through classes provided in packages.
- contains fundamental classes and interfaces closely tied to the language and runtime system.
- I/O and networking access the platform file system, and more generally networks through the, and packages. For networking, SCTP is available through .
- Mathematics package: provides mathematical expressions and evaluation, as well as arbitrary-precision decimal and integer number datatypes.
- Collections and Utilities : built-in Collection data structures, and utility classes, for Regular expressions, Concurrency, logging and Data compression.
- GUI and 2D Graphics: the AWT package basic GUI operations and binds to the underlying native system. It also contains the 2D Graphics API. The Swing package is built on AWT and provides a platform-independent widget toolkit, as well as a Pluggable look and feel. It also deals with editable and non-editable text components.
- Sound: interfaces and classes for reading, writing, sequencing, and synthesizing of sound data.
- Text: deals with text, dates, numbers and messages.
- Image package: and provide APIs to write, read, and modify images.
- XML: SAX, DOM, StAX, XSLT transforms, XPath and various APIs for Web services, as SOAP protocol and JAX-WS.
- CORBA and RMI APIs, including a built-in ORB
- Security is provided by and encryption services are provided by .
- Databases: access to SQL databases via
- Access to Scripting engines: The package gives access to any conforming Scripting language.
- Applets: allows applications to be downloaded over a network and run within a guarded sandbox
- Java Beans: provides ways to manipulate reusable components.
- Introspection and reflection: java.lang.Class represents a class, but other classes such as Method and Constructor are available in .
Licensing
Prior licenses
Before the release of OpenJDK, the JDK was based on a proprietary license.
Following their promise to release a fully buildable JDK based on almost completely free and open-source code in the first half of 2007, [3] Sun released the complete source code of the Class Library under the GPL on May 8, 2007, except some limited parts that were licensed by Sun from third parties who did not want their code to be released under an open-source license. [4] Sun’s goal was to replace the parts that remain proprietary and closed source with alternative implementations and make the Class Library completely free and open source.
Until December 2010, the remaining encumbered part of the JDK was made available by Sun then Oracle as Binary Plugs [5] which were required to build the JDK but not necessary to run it., the only part of the Class library that remained proprietary and closed-source (4% for OpenJDK 7, [6] and less than 1% and OpenJDK 6 [7] [8] ) was: [9] [10]
Since the first May 2007 release, Sun, with the help of the community, released as open-source or replaced with open-source alternatives almost all the encumbered code:
- All the audio engine code, including the software synthesizer, became open source. [11] The closed-source software synthesizer has been replaced by a new synthesizer developed specifically for OpenJDK called Gervill, [12]
- All cryptography classes were released as open-source, [13]
- The code that scales and rasterizesfonts uses open source FreeType[14][15][16]
- The native color management uses open-source LittleCMS. [15] There is a pluggable layer in the JDK, so that the commercial release of Java can use the original, proprietary color management system and OpenJDK can use LittleCMS.
- The anti-aliasing graphics rasterizer code uses the open source Pisces renderer used in the phoneME project. [15][17][18]
- The JavaScript plugin is open source (the JavaScript engine itself was open source from the beginning). [19]
Open source release
Beginning in December 2010, all the so-called binary plugs were replaced by open source replacements, making the entire JDK open. [20]
Alternative implementations
GNU Classpath is the other main free software class library for Java. Contrary to other implementations, it only implements the Class Library, and is used by many free Java runtimes (like Kaffe, SableVM, JamVM).
Apache Harmony was another free software class library. Its aim was to implement the other parts of the Java stack (Virtual Machine, Compiler, and other tools required for any Java implementation).
See also
External links
- Java SE Main page
- Java SE API documentation
- 1.7 (early development)
- 1.6 (stable, current)
- 1.5 (stable)
- 1.4 (stable)
- 1.3 (obsolete)
Notes and References
- Web site: How Classes are Found. Oracle Corporation. 2015-12-05.
- Web site: JDK Module Summary. Oracle Corporation. 2015-10-23. 2015-11-29.
- http://www.sun.com/software/opensource/java/faq.jsp#b4
- Web site: Open JDK is here!. Rich Green. Sun Microsystems. 2007-05-08. 2011-11-25.
- Web site: OpenJDK Binary Plugs. Sun Microsystems. 2007-05-08. 2011-11-25. https://web.archive.org/web/20120826021741/http://openjdk.java.net/legal/binary-plugs-2007-05-08.html. 2012-08-26. dead.
- Web site: Plans for OpenJDK. Fitzsimmons. Thomas. 2007-05-18. 2007-05-22.
- Web site: OpenJDK to replace IcedTea in Fedora 9 . Angel . Lillian . 2008-03-13 . 2008-04-05 . dead . https://archive.today/20121210052442/http://langel.wordpress.com/2008/03/13/openjdk-in-fedora-9/ . 2012-12-10.
- Web site: OpenJDK in Fedora 9!. Wade. Karsten. redhatmagazine.com. Thomas Fitzsimmons updated the Fedora 9 release notes source pages to reflect that Fedora 9 would ship with OpenJDK 6 instead of the IcedTea implementation of OpenJDK 7. Fedora 9 (Sulphur) is due to release in May 2008.. 2008-03-13. 2008-04-05. https://web.archive.org/web/20080421100346/http://developer.redhatmagazine.com/2008/03/12/openjdk-to-replace-icedtea-in-fedora-9/. 2008-04-21. dead.
- Web site: Plans for OpenJDK . Herron . David . 2007-10-04 . 2007-10-09 . dead . https://web.archive.org/web/20071011014156/http://weblogs.java.net/blog/robogeek/archive/2007/10/openjdk_encumbr.html . 2007-10-11.
- Web site: OpenJDK 6 b10 source posted. 2008-05-30. 2008-06-01.
- http://openjdk.java.net/projects/audio-engine/ audio-engine project page
- Web site: Gervill — Software Synthesizer . https://archive.today/20111004052704/https://gervill.dev.java.net/ . dead . 2011-10-04 . 2008-06-01.
- Web site: Crypto has been added to OpenJDK. 2007-09-27. 2007-10-07.
- http://openjdk.java.net/projects/font-scaler/ font-scaler projectpage
- http://openjdk.java.net/groups/2d/ Java2D project page
- Web site: Freetype font rasteriser. 2007-08-07. 2007-11-24.
- https://phoneme.dev.java.net/ phoneme.dev.java.net/
- http://openjdk.java.net/projects/graphics-rasterizer/ graphics-rasterizer project page
- Web site: Javascript is encumbered and there is no javascript plugin support.. IcedTea. Changing Summary. JavaScript is no longer encumbered, but we still need liveconnect support.. 2008-03-11. 2008-06-01.
- Web site: OpenJDK7 and OpenJDK6 Binary Plugs Logic Removed. Kelly O’Hair. Oracle Corporation. December 2010. 2011-11-25.
This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article «Java Class Library».
Except where otherwise indicated, Everything.Explained.Today is © Copyright 2009-2022, A B Cryer, All Rights Reserved. Cookie policy.
Стандартная библиотека классов Java
Стандартная библиотека классов позволяет существенно упростить процесс разработки программ на языке программирования Java. Классы стандартной библиотеки классов размещены в пакете с именем java и его подпакетах . Например , базовые классы, необходимые для работы любой java-программы, находятся в подпакете lang пакета java (java.lang). Пакет java.lang по умолчанию импортируется в каждый модуль компиляции, поэтому команду import java.lang.*; писать в программе не обязательно. Пакет (package) — это некий контейнер для классов, который задает для классов пространство имен, каталог для размещения и пакетный уровень доступа. Например , класс Date стандартной библиотеки java размещается в пакете java.util. На слайде номер 11 показаны каталоги, в которых находится файлы Date.java и Date.class. 12
Структура, компиляция и выполнение Java-программы
Структура, компиляция и выполнение Java-программы .
В примере 1 файл с программой имеет имя Hello и расширение .java (Hello.java). Файл с программой набран и сохранен с помощью программы Geany. В командной строке запустим компилятор javac Hello.java и получим файл Hello.class, который можно запустить на выполнение при помощи команды java Hello. Если установлен JDK и добавлен путь “ C:\Program Files\Java\jdk1.8.0_05\bin” к системной переменной PATH, то в Geany можно не только набрать программу на Java, но также ее можно компилировать и выполнять. Рассмотрим исходный код программы примера 1 . Вся программа состоит из одного класса с именем Hello. Класс Hello находится в пакете по умолчанию , которому соответствуют папка pr1_java , в которой находится класс Hello. У этого класса имеется единственный метод main. С метода main начинается выполнение программы. Все приложения Java должны иметь один метод main(). Давайте расшифруем каждое слово в коде. Ключевое слово import указывает пакет, в котором находится стандартный класс Date. Ключевое слово public — это спецификатор доступа. Когда члену класса предшествует public, то к этому члену возможен доступ из кода, внешнего по отношению к классу, в котором описан данный метод. В данном случае, метод main объявлен как public для того, чтобы JVM могла обратиться к этому методу. Ключевое слово static позволяет методу main() вызываться без потребности создавать объект класса Hello. Это важно, потому что JVM вызывает этот метод в первую очередь. Следовательно этот метод должен быть как static и не должен зависеть от экземпляров любого создаваемого класса.Через переменную-массив args типа String методу main() могут передаются параметры командной строки. Оператор System.out.println(“Hello, мир») посылает строку текста в стандартный поток вывода, т. е. на экран. Оператор Date d = new Date() создает объект d класса Date и инициализирует его текущей датой и временем. Оператор System.out.println(«Date:»+d.toString()) посылает сформированную строку текста на экран.