About JAVA – learn advanced things

The builder Hello () initializes the frame or frame by calling method setDefaultCloseOperation (int) inherited from JFrame to establish operations by default when control of closure in the title bar is selected to the value WindowConstants.DISPOSE_ON_CLOSE. This makes released the funds taken out of the window when it is closed, and not simply hidden, which allows the virtual machine and the program finish their execution. Then establishing an object type JLabel with the text “Hello, world!”, And is added to the framework using the method add (Component), inherited from the Container class. The method pack (), inherited from the Window class, is invoked to scale the window and distribute its content.

The method main () is called by the JVM at the beginning of the program. Create an instance of the class Hello and makes the window is shown by invoking the method setVisible (boolean) of the superclass (class of inheriting) with a true parameter. See, once the frame is drawn, the program does not end when it leaves the method main (), because the code is dependent on a thread and launched an independent, and that will remain active until all the windows have been destroyed.

Operating Environments

The design of Java, its strength, supported by the industry and its easy portability have made Java one of the languages with higher growth and extent of use in various fields of information technology industry.

In mobile devices and embedded systems

Since the inception of the specification J2ME (Java 2 Platform, Micro Edition), a version of the Java Runtime Environment and highly optimized small, specially developed for the market for consumer electronics devices has produced a revolution in terms of the extension Java is concerned.

You may find microprocessors designed specifically to execute bytecode Java and Java software for smart cards (JavaCard), mobile phones, pagers, set-top-boxes, TV tuners and other small appliances.

The development model of these applications is very similar to the applets browsers except that in this case are called MIDlets.

See Sun Mobile Device Technology

In the Web browser

Since the first version of java there is the possibility of developing small applications (applets) in Java that can then be embedded in an HTML page to be downloaded and executed by the web browser. These mini-applications run on a JVM that the browser is configured as an extension (plug-in) in a security context configurable restricted to prevent the local implementation of potentially malicious code.

The success of such applications (vision equipment Gosling) was not really expected because of various factors, perhaps the most important being the slow and reduced width banda of communications at the time that limited the size of applets that are embedded in the browser. The subsequent emergence of alternatives (dynamic web applications server) left a small field of use for this technology, now being relegated primarily to specific components for intermediation from a dynamic web application server with devices located on the client machine running browser.

The Java applets are not the only technology (although the first) of complex components embedded in the browser. Other technologies may be similar: Microsoft ActiveX, Flash, Java Web Start, etc..

In server systems

In part server, Java is more popular than ever, since the emergence of the specification of Servlets and JSP (Java Server Pages).

Until then, the dynamic web server applications that existed were based primarily on components CGI languages and interpreted. Both had various drawbacks (mainly slow, high burden of memory and computational or propensity for mistakes by his dynamic interpretation).

The servlets and JSPs represented a major breakthrough because:

* The API programming is quite simple, flexible and expandable.

* Servlets are not independent processes (such as CGIs) and therefore are executed within the same process that the JVM significantly improving performance and reducing the burden computational and memory required.

* The JSPs are compiled pages that are dynamically (or pre-compiled prior to distribution) so that the code that achieves a substantial advantage in performance compared to many languages interpreted.

The specification of Servlets and JSPs defines an API programming and requirements for a container (server) within which these components can be deployed to form complete dynamic web applications. Today there are many containers (free trade) compatible with these specifications.

Since its expansion between the developer community, these technologies have given way to development models with much more elaborate frameworks (eg Struts, Webwork) that overlap on servlets and JSPs to achieve a working environment much more powerful and segmented where the specialization of roles possible (developers, graphic designers, …) and facilitate reuse and robustness of code. Despite all this, the underlying technologies (servlets and JSPs) are substantially the same.

This working model has become a de-facto standard for developing dynamic web applications server and other technologies (pe. ASP) have relied on him.

In desktop applications

Today there are many user-based graphics applications in Java. The Java Runtime Environment (JRE) has become a routine component in the PC user most popular operating systems used in the world. In addition, many Java applications include the inside of the application package so that its implementation in any PC.

In the first versions of the Java platform there were significant limitations in the APIs graphical development (AWT). Since the appearance of the library Swing the situation improved substantially and subsequently with the emergence of bookstores as SWT render development of desktop applications and complex with great dynamism, usability, etc.. is relatively straightforward.

Supported Platforms

A version of the Java Runtime Environment JRE (Java Runtime Environment) is available in most desktops. However, Microsoft has not included it in its default operating systems. In the case of Apple, it includes a version of JRE on its own operating system, Mac OS. It is also a product that appears by default on most Linux distributions. Due to incompatibilities between different versions of the JRE, many applications prefer to install its own copy of the JRE before entrusting their fate to the application installed by default. The developers of Java applets or should insist to users in updating JRE or develop under an old version of Java and verify the proper functioning in later versions.

Industry related

Sun Microsystems, as a creator of the Java platform and the JDK, maintains strong policies to maintain a specification language [1] as well as the virtual machine [2] through the JCP. It is because of this effort which maintains a de facto standard.

There are countless companies that develop applications for Java and / or are directed to this technology:

* The mobile phone industry is strongly influenced by Java technology.
* The development environment Eclipse has taken an important place among the community of Java developers.
* The Apache Foundation also has a significant presence in the development of libraries and server components based on Java.
* IBM, BEA, Iona, Oracle, … are large companies with vested interests and products and in Java.

Criticisms

Harold said in 1995 that Java was created to open a new path in managing complex software, and is generally accepted that has behaved well in that aspect. But one can not say that Java has no cracks, or fully adapted to all styles of programming, all settings, or all the needs.

General

* Java has not provided skills standards for floating point arithmetic. The IEEE standard for 754 “Standard for Binary Arithmetic in Floating Point” appeared in 1985 and since then is the standard for the industry. And although the arithmetic floating Java (which changed from November 13, 2006, when it opened the source code and adopted the GNU license, besides the already existing) se basa largely on the IEEE standard, not still supports some features. More information on this subject can be found in the final section of external links.

The language

* In a strict sense, Java is not a completely object-oriented language, unlike, for example, Ruby and Smalltalk. For reasons of efficiency, Java has relaxed to some extent the paradigm object oriented, and thus for example, not all values are objects.
* Java code can sometimes be redundant in comparison with other languages. This is partly due to the frequent statements of rates and conversions type manual (casting). It is also due to the unavailability of operators overloaded, and a relatively simple syntax. However, J2SE 5.0 introduces elements to try to reduce redundancy, as a new building for loops” ‘foreach”’.
* Unlike C + +, Java does not have operators overload defined by the user. However this was a design decision that can be seen as an advantage, since this characteristic can make programs difficult to read and maintain.

Appearance

The outward appearance (” ‘look and feel”’) applications GUI (Graphical User Interface) written in Java using the platform Swing often differs from that show native applications. Although the developer can use the toolkit AWT (Abstract windowing Toolkit) that generates graphic objects of the native platform, the AWT is not capable of advanced graphics features without sacrificing portability between platforms, because each has a different set of APIs , Especially for high-level graphic objects. The tools of Swing, written entirely in Java, avoids this problem by building the graphic objects from the drawing basic mechanisms that should be available on all platforms. The downside is the extra work required to achieve the same appearance of the target platform. Although this is possible (using GTK + and the look-and-feel of Windows), most users do not know how to change the appearance that is provided by default one that adapts to the platform. Mention deserves the optimized version of the language.

Performance

The performance of an application is determined by many factors, so it is not easy to make a comparison that is totally objective. At runtime, a Java application performance depends more on the efficiency of the compiler, or JVM, that of the intrinsic properties of language. The Java bytecode can be interpreted at runtime by the virtual machine, or compiled to load the program, or during the execution itself, to generate native code that runs directly on the hardware. If it is interpreted, it will be slower than using the machine code intrinsic target platform. If compiled during the initial charge or enforcement, the penalty is at the time needed to complete the compilation.

Some characteristics of the language itself carry a penalty in time, although not unique Java. Some of them are checking the limits of arrays, check-in time delivery rates, and indirección of virtual functions.

Using a garbage collector for automatically removes those objects not required adds an overload that can affect performance, or be barely noticeable, depending on the technology of the collector and the application. The JVM using modern garbage collectors who, thanks to fast memory management algorithms, get some applications that can run more efficiently.

The yield of a compiler and JIT compilers natives may be similar, although the distinction is unclear at this point. The compilation by the JIT can consume a considerable time, mainly an inconvenience for applications or short-term with a lot of code. However, once compiled, program performance can be comparable to that achieved native compilers target platform, including numerical tasks. Although Java does not allow for the expansion manual calls to methods, many JIT compilers perform this optimization during the burden of implementation and can leverage information runtime to carry out efficient processing during the execution of the application itself. This dynamic recompilation, as provided by the Sun HotSpot virtual machine, you can get to improve the outcome of traditional static compilers, thanks to data that are available only during the time of execution.

Java was designed to provide security and portability, and offers no direct access to hardware architecture or the address space. Java does not support expansion of assembly code, although applications can access features low-level libraries using native (JNI, Java Native Interface).

Resources

JRE

The JRE (Java Runtime Environment, or runtime Java) is the software necessary to run any application developed for the Java platform. The end-user uses the JRE as part of software packages or plug-ins (or connectors) in a Web browser. Sun also offers the Java 2 SDK, or JDK (Java Development Kit) within which lies the JRE, and includes tools like the Java compiler, Javadoc to generate documentation or scrubber. It can also be obtained as a separate package, and can be seen as the necessary environment to run a Java application, while a developer must also have other facilities of the JDK.

Components

* Libraries Java, which are the result of compiling the source code developed by whoever implements the JRE, and offering support for development in Java. Examples of these libraries are:
o The central libraries, which include:
+ A collection of libraries to implement data structures such as lists, arrays, trees and sets.
+ Libraries for analysis of XML.
+ Security.
+ Libraries internationalization and localization.
Libraries or integration, allowing communication with external systems. These libraries include:
+ The API for access to databases JDBC (Java DataBase conectivity).
+ The interface JNDI (Java Naming and Directory Interface) for directory services.
+ RMI (Remote Method Invocation) and Corba for the development of distributed applications.
or Libraries for the user interface, including:
+ The toolkit native AWT (Abstract windowing Toolkit), which provides components GUI (Graphical User Interface), mechanisms to use and manage their associated events.
+ Libraries Swing, built on AWT but offered no native implementations of the components of AWT.
+ APIs for catching, processing and audio playback.
* An implementation dependent on the platform that runs the Java Virtual Machine (JVM), which is responsible for implementing the code of bookstores and external applications.
* Plugins or connectors that allow applets run in Web browsers.
* Java Web Start, for the distribution of Java applications through the Internet.
* Documentation and licensing.

APIs

Sun defines three platforms in an attempt to fill a variety of application environments. It has distributed many of its APIs (Application Program Interface) so that belong to each of the platforms:

* Java ME (Java Platform, Micro Edition) or J2ME – oriented environments with limited resources, such as cell phones, PDAs (Personal Digital Assistant), etc..
* Java SE (Java Platform, Standard Edition) or J2SE – for mid-range environments and workstations. Here lies the average user on a PC desktop.
* Java EE (Java Platform, Enterprise Edition) or j2ee – aimed at distributed environments or Internet business.

Classes in the Java APIs are organized into groups called disjuntos packages. Each package contains a set of interfaces, classes and related exceptions. Information on the packages offered by each platform can be found in the documentation of it.

All the APIs is controlled by Sun Microsystems along with other entities or persons through the program JCP (Java Community Process). Companies or individuals participating in the JCP can influence an active role in the design and development of the APIs, which has been a source of controversy.

In 2004, IBM and BEA publicly supported the idea of creating an implementation of open source (open source) Java, something that Sun, dated 2006, has refused.

Extensions and related architectures

The Java extensions are in packages that hang from the root javax: javax .*. Not included in the JDK or JRE. Some of the extensions and architectures closely linked to Java are:

* Java EE (Java Platform, Enterprise Edition; before j2ee)-for distributed applications-oriented business environment
* Java ME (Java Platform, Micro Edition; before J2ME)-for devices with limited resources such as cell phones and PDAs
* JMF (Java Media Framework)
* JavaHelp
* JavaMail
* JNDI (Java Naming and Directory Interface)
* JSML (Java Speech API Markup Language)
* JDBC (Java Database Connectivity)
* JDO (Java Data Objects)
* JAI (Java Advanced Imaging)
* JAIN (Java APIs for Integrated Networks)
* JDMK (Java Dynamic Management Kit)
* Jini (a network architecture for building distributed systems
* Jiro
* Java Card
* JavaSpaces
* JML (Java Modeling Language)
* JMI (Java Metadata Interface)
* JMX (Java Management Extensions)
* JSP (JavaServer Pages)
* JSF (JavaServer Faces)
* NYI (Java Native Interface)
* JXTA (Protocols open for virtual networks Peer-to-peer or P2P)
* Java 3D (A high-level API for 3D graphics programming)
* JOGL (Java OpenGL-A low-level API for programming using OpenGL graphics)
* LWJGL (Light Weight Java Game Library-A low-level API for access to OpenGL, OpenAL and several input devices)
* Marfa (Modular Audio Recognition Framework)
* OSGi (Dynamic Remote Service Management and Maintenance)

Java into open source

Java has become a language with a massive deployment in all environments (personal and business). The Sun maintains control over it generates resistance in the community of companies with strong interests in Java (eg IBM, Oracle) and obviously in the community of free software developers.

The evolution based on a committee with the participation of all concerned is not enough and the community has long demanded the release of APIs and libraries of the core JDK.

How far Java software is free?

In December 2006, Sun is in full relaunch of its Java platform under the GNU license GNU. When this change licensing finished, we hope that Java is no longer a trap (source (see note is in the yellow box))

Commitment from Sun Microsystems to open source

The importance of open source in connection with Java can be seen among other things, that the president and CEO of Sun, Jonathan Schwartz, has challenged the company to offer for the entire open source software that produces Sun (source), and Sun have long since started to bet on open source when released StarOffice (now called OpenOffice).

Sun has contributed more lines of open source than any other organization (source) Richard Stallman also believes that it (source)

* The success of open source – Article seat on the official site in Spanish Sun Microsystems, which speaks of the bet by Sun Microsystems open source.

Free alternative

There are alternatives sufficiently mature environment for the development and implementation of Java with a wide coverage of features regarding commercial deployments of Sun, IBM, Bea, …

* Blackdown Java for Linux, includes a plugin for Mozilla
* GNU Classpath GNU – currently being merged with libgcj Compiler for Java GNU
* Apache Harmony Apache

Criticism concerning Java and FOSS

* Free But Shackled – The Java Trap, Richard Stallman, April 12, 2004. (reply, James Gosling)
or Spanish translation of this article: Free but shackled. The trap of Java. (Note that there is a note in a yellow box that talks about the current situation regarding what was said in that article)

Note that this article was written before the release of the source code of Java. At present the position of the Free Software Foundation and Richard Stallman have changed, both wanted for their use in free software.

Free software based on Java

* Azureus
* Limewire
* Radio irat
* Source Java has a list of free software (GNU licenses, LGNU, Apache, BSD, …) done in Java.

See also

* Java syntax
* Java keywords
* Java Virtual Machine
* Java Platform
* Java applet
* Java Platform, Standard Edition (SE Java, J2SE)
* JAVA
* Comparison of Java and C + +
* Comparison of Java and C #
* Java User Group
* Java Community Process
* JavaOne
* Join Java Programming Language
* Javapedia
* Inferno Operating System

References

* Jon Byous, Java technology: The early years. Sun Developer Network, undated [ca. 1998]. Retrieved April 21, 2005.
* James Gosling, A brief history of the Green project. Java.net, undated [ca. Q1/1998]. Retrieved April 22, 2005.
* James Gosling, Bill Joy, Guy Steele, and Gilad Bracha, The Java language specification, third edition. Addison-Wesley, 2005. ISBN 0-321-24678-0.
* Tim Lindholm and Frank Yellin. The Java Virtual Machine specification, second edition. Addison-Wesley, 1999. ISBN 0-201-43294-3.

Examples Dynamic Programming

* No execution of tasks in minimum time on a system of two processors A and B
* Programs disk
* Problem stamps with dynamic programming
* Problem backpack with dynamic programming
* Problem product of a sequence of dynamic programming with parent
* Problem of currencies with dynamic programming
* Way of minimum cost between two nodes of a directed graph
* Problem of the division of weight
* Problem cows with dynamic programming
* Problem of Change Dynamics word Programming in Java

Notes

1. ? Specifying the Java language
2. ? Specifying the Java Virtual Machine

External Links

Wikibooks

* Collaborate in textbooks textbooks hosts a book or manual on Programming in Java.
* Perl modules on CPAN in Java (in English)

Sun

* Official site of Sun Microsystems in Spanish
* Official site for Java developers, etc.
* Official Site Java for non-technical users not advanced
* The Java Language Specification, Third Edition Specification official Java language
* Tutorial on the Sun Java
* White Paper original Java, 1996
* Test your VM
* Course Free Introduction to Java

Petitions for the specification of Java (Java Specification Requests)

There are several JSRs related to the Java language and APIs kernel.

* Add JSR 14 Generic Types To The Java Programming Language (J2SE 5.0)
* A Simple JSR 41 Assertion Facility (J2SE 1.4)
* JSR 47 Logging API Specification (J2SE 1.4)
* JSR 51 New I / O APIs for the Java Platform (J2SE 1.4)
* JSR 59 J2SE Merlin Release Contents (J2SE 1.4)
* Application Isolation API JSR 121 (not yet included)
* JSR 133 Java Memory Model and Thread Specification Revision (J2SE 5.0)
* JSR 166 Concurrency Utilities (J2SE 5.0)
* JSR 175 A Metadata Facility for the Java Programming Language (J2SE 5.0)
* JSR 176 J2SE 5.0 (Tiger) Release Contents (J2SE 5.0)
* Extending the JSR 201 Java Programming Language with Enumerations, autoboxing, Enhanced for loops and Static Import (J2SE 5.0)
JSR 203 * More New I / O APIs for the Java Platform ( “NIO.2″) (Java SE 7)
* JSR 204 Unicode Supplementary Character Support (J2SE 5.0) – support for Unicode 3.1
* JSR 270 Java SE 6 ( “Mustang”) Release Contents (Java SE 6)
* JSR 901 Java Language Specification (J2SE 5.0)

Tutorials

* The Java Tutorial Sun Microsystems (online)
* David Flanagan, Java in a Nutshell, Third Edition. O’Reilly & Associates, 1999. ISBN 1-56592-487-8
* Thinking in Java, by Bruce Eckel (online)
* Java Course, A.B. Downey.
* Introduction to Programming Using Java Text online David J. Eck
* How to Think Like a Computer Scientist version of Java
* An introduction to Computer Science using Java By Bradley Kjell. This text focuses on the principles and fundamentals of programming languages and computers in general, and uses Java as it’s language of instruction.
* A Java tutorial by Alhoori Hamed, an instructor at the University of Bahrain.

* Full Java Tutorial

* In Castilian:
Choosing or collections in Java
Course practical or Java
or Java applets
Basic or Java Tutorial
Manual or Java
Bits or Java
or Introduction to Java
Collection or ‘Java butt’ e-book (University of Malaga. Spain)

Video Tutorials

* Videotutoriales basic Java

Resources

* Java (Sun)
* Java Community of developers Mexico Mexicans.
* Software Development Java Virtual Community for exchanging information in Castilian on software development in Java for professional practitioners, teachers and students.
* Computer-Books.us collection of books on Java available for free download.
* Project Javapedia
* Wiki Java.net
* JavaRSS.com portal websites on Java.
* DeveloperWorks Java Zone – Community Resource Java
* JavaWhat.com Resource Directory Java
* Report, examples of programs, mini-tutorials, sources of information
* Development in Java JavaDesarrollo
* Examples, programs, forums and manuals on java

IDEs for Java

* BEA Workshop – commercial software, developed by BEA Systems, integrated with BEA WebLogic
* BlueJ – free, developed as a research project universiatario. BlueJ is also an interactive environment suitable for learning Java
* Eclipse – free and open source, Eclipse is developed by the Eclipse Foundation
* IntelliJ idea – commercial software, IntelliJ idea is developed by JetBrains
* JGrasp – Free software developed by the Department of Computer Science and Software Engineering at the Samuel Ginn College of Engineering at the University of Auburn. It is a very slight development environment for Java, C, C + +, Objective C, Ada and VHDL. Integra UML diagrams for Java diagrams and Control Structures.
* JBuilder – commercial software (there is a free version). JBuilder is developed by Borland
* JCreator – commercial software (there is a free version) developed by Xinox
* JDeveloper – SDI Oracle Corporation and integrated with Oracle Application Server
* NetBeans – IDE and platform basis for rich desktop applications (Apps Rich) free open source developed by NetBeans.org
* Sun Java Studio Enterprise – commercial software (free for members of Sun Developer Network), developed by Sun Microsystems
* Rational Application Developer for WebSphere Software – commercial software, developed by IBM, integrated with WebSphere Application Server

OpenJDK – the free version of the Java development platform

OpenJDK is the free version of the Java development platform.

History

In 1995, Sun Microsystems Launches Version 1.0 of the Java JDK under the slogan of “Write once, run everywhere”, initiating an important chapter in the software development industry. In 1998 version 1.1 had two million downloads.

Although it was possible to create free software with Java because it is a programming language with an open specification, its performance depends on the Java virtual machine, which was non-free software. Richard Stallman called this situation as “the Java trap”, [1] because although the program is free software developed, this may find it difficult to spread in environments free software. This resulted in all GNU / Linux distributions Java Virtual Machine is not included, since the only legal mechanism was downloaded from the Web own Sun.

Various projects were created to implement a Java virtual machine with free license, including Kaffe [2] and Armony [3] as well as GCJ [4] that allow compile the source code and Java bytecodes into native code. For the development of libraries was created based on GNU Classpath project. [5]

Since 1998, Sun created a development process open to Java technology, through the Java Community Process program. The program has since changed, allowing an increasingly open development of the Java platform under the license JRL. [6] In 2006, the Java SE 6 was carried out with a great community involvement. However, Sun showed undecided in the licence which would be released, but was seen using the license Common Development and Distribution License (CDDL) used by OpenSolaris.

In August 2006, Sun changed its license so that the binary could include the Java virtual machine in GNU / Linux distributions.

On November 13, 2006, [7] after 10 years of development, Sun announced the launch versions of Java SE 6 and SE 7 under GPL version 2. [8] [9] When he was appointed OpenJDK project and included initially the HotSpot Java virtual machine, the Java compiler javac and the help system JavaHelp 2.0. He also announced the release of the rest of the platform over the first half of 2007, with the exception of a few components with licensing problems unrelated to Sun.

Development Project

The project has its own website, [10] a portal for the development community, [11] blogs. [12] and has mailing lists. [13] It also has an IRC channel, [14] and for a Wiki promote ideas [15] and with a page for reporting errors. [16]

The tool that is used for development is NetBeans, which has a license Common Development and Distribution License (CDDL), and used as CVS repository. The growth of JDK and NetBeans are closely linked because they share the same community development. To help with the project through patches, the agreement should be signed Sun Contributor Agreement (SCA). Changes in the language are controlled through the Java Community Process.

Structures organizational decision

The OpenJDK community [17] includes two sections, one public, where the OpenJDK project among others, and a private section where you can only participate if a member and has accepted the JRL license. [18] Although projects JDK6 JDK7 and are in the public section, maintain a license JRL.

It is possible to register a new project, which must pass through a stage of incubation in the jdk-incubator [19] until this is sufficiently mature.

It can take two roles in this community:

* Developer, which uses the API and tools for building applications. Not contributes code in the JDK.

* Contributor, is one developer that has signed the Sun Contributor Agreement [20] and has the ability to make contributions as patches or improvements to the source.

Since 1998 the development of Sun’s Java platform is done via the Java Community Process program called [21] (JCP) coordinated by the Process Management Office. It has nearly 700 members, which perform proposals through formal documents called Java Specification Requests (JSR). There are currently 926 JSR of which 90 are under development for the new version of the platform.

PCB includes panels of experts who review the JSR that are included in the official list.

There are two executive committees (EC) for editions of the Java platform, Standard / Enterprise and Micro Edition. They approvals process and the JSR to be developed.

Radiography

The analysis according to the model costing Cocom with which calculates an estimate of the cost of producing software under a model of Software Engineering closed. Applying the SLOCCount tool: [22]
Cost estimates javac Value Concept
Total 90,812 lines of code
Years of development 1.76
Effort person-years 12.96
Estimated cost of development 3,073,916 U.S. dollars

To get an estimate of costs is taken into consideration the salary of 56,286 U.S. dollars / year, which is the average salary of a programmer in the United States and then multiply that result by 2.40 which includes any extra spending different from programmers as can be: light, telephone, stationery and so on.
Programming languages used in javac lines of code language%
Java 88.346 97.28%
SH 2.466 0.10%

These are the tables for HotSpot:
Cost estimates HotSpot Value Concept
Total 475,290 lines of code
Years of development 3.40
Effort person-years 129.37
Estimated cost of development 17,476,249 U.S. dollars
Programming languages used in hotspot lines of code language%
CPP 376,211 79.15%
Java 87,585 18.43%
ansic 8,614 1.81%
ASM 1,724 0.36%
SH 1,156 0.24%

Java Runtime Environment – basic things

JRE is an acronym for Java Runtime Environment (runtime Java) and corresponds to a set of utilities that allows the execution of Java programs on all supported platforms.

The JRE consists of a JVM (Java virtual machine) that is the program that interprets the Java code and libraries in addition to standard classes that implement the Java APIs. Both JVM and API should be consistent with each other, hence they are distributed so large.

A user needs only the JRE to run applications developed in Java, while for developing new applications in that language requires a development environment called JDK, also JRE (bare minimum) includes, among others, for a compiler Java.

About JAVA applet

A Java applet is an applet written in Java. The Java applets can run on a web browser using the Java virtual machine (JVM), or in appletviewer Sun.

Its features include an outline of security that allows applets that run on your computer without access to sensitive parts (eg. Can not write files), unless oneself getting the necessary permits in the system; The disadvantage of this approach is that the supply of permits is cumbersome for the common user, which plays against one of the goals of Java applets: provide an easy way to run applications from a web browser.

In Java applet (Subprogramme), is a program that can inscrustarse in an HTML document that is on a Web page, When a browser load a Web page containing an applet, this is discharged into the Web browser and begin to run this allows us to create software that anyone can run with just load the Web page in your browser.

The browser that loads and executes the applet is known in generic terms such as container applets. The Software Development Kit for Java 2 (j2sdk) 1.4.1 includes the trash container called Applets appletviewer to test applets before inscrustarlso in a Web page.

Advantages

A Java applet can have some or all of the following advantages:

* Run on Linux, Windows and Mac OS are multiplatform
* The same applet can work on “all” versions of Java, and not just the latest version of the plug-in. However, if an applet requires a later version of the JRE, the customer will be forced to wait for the great shock.
* It is supported by most Web browsers
* Can be stored in the cache of most Web browsers, so it will charge quickly when reload the Web page, although it can be jammed into the cache, causing problems when new versions are released.
* You can have full access to the machine he is running, if the user permits it
* You can run with speeds comparable (but generally slower) to the other compiled languages such as C + +, but many times faster than JavaScript
* You can move the work server to the client, making a solution more scalable Web taking into account the number of users / customers

Disadvantages

A Java applet can submit any of the following disadvantages:

* Requires the plug-in Java, which is not available by default in all web browsers.
* Sun has not created an implementation of the plug-in for 64-bit processors
* You can not start the execution until the Java Virtual Machine is running, and this can take time when you first run an applet.
* If you are not signed as reliable, has limited access to the system user – particularly not have direct access to the hard drive of the client or the clipboard.
* Some organizations only allow the installation of software to administrators. As a result, many users (with no privileges to install the plug-in in your browser) can not see applets.
* An applet may require a specific version of the JRE.

Examples Included in Sun JDK

* Applet TicTacToe.
* DrawTest applet.
* Applet BarChart.
* Applet Animator.
* ArcTest applet.
* Blink applet.
* Clock applet.
* Applet GraphicsTest.
* Applet imagemap.
* Applet MoleculeViewer.
* JumpingBox applet.

How to create an applet

To create an applet need to write a key class applet package java.applet .*;

import java.applet .*;
public class MiApplet extends Applet
(
/ / Body””applet.
)

The previous code declares a new class MiApplet that inherits all the capabilities of the class Java applet. The result is a file MiApplet.java.

Once created the class that composes the applet, we write the rest of the code and then compile, getting the file MiApplet.class. In order to create the applet is needed to compile the Java code in an interpreter.

import java.applet .*;
import java.awt .*;
import java.util .*;
Import java.text.DateFormat;

public class MiApplet extends applet implements Runnable
(
Thread private thread = null;
Private Font source;
private String horaActual = “00:00:00″;

public void init ()
(
source = new Font ( “Verdana”, Font.BOLD, 24);
)
public void start ()
(
if (thread == null)
(
thread = new Thread (this, “Clock”);
hilo.start ();
)
)
public void run ()
(
Thread hiloActual = Thread.currentThread ();
while (thread == hiloActual)
(
/ / get the current time
Calendar lime = Calendar.getInstance ();
Date hour = cal.getTime ();
Dateformat df = DateFormat.getTimeInstance ();
horaActual = df.format (time);
repaint ();
try
(
Thread.sleep (1000);
)
catch (InterruptedException e) ()
)
)
public void paint (Graphics g)
(
/ / Draw a rectangle around the container
g.draw3DRect (1, 1, getSize (). width-3, getSize (). height-3, false);
/ / Set the Source
g.setFont (source);
/ / Show Time
g.drawString (horaActual, 14.40);
)
public void stop ()
(
thread = null;
)
)

Finally, to run the applet must create a Web page that refers to it. The HTML tag that allows you to do that is <applet>:

<html>
<applet code=”MiApplet.class” width=”370″ height=”270″>
</ applet>
</ html>

Obviously the parameters “MiApplet.class”, “370″ and “270″ can be modified.

About Java – all things about JAVA

Java is a programming language object-oriented developed by Sun Microsystems in the early 90. The language in itself takes a lot of its syntax from C and C + +, but has a simpler model objects and eliminates low-level tools, which often lead to many mistakes, as the direct handling of pointers or memory.

The Java applications are typically compiled in a bytecode, although compiling a native machine code is also possible. At the time of execution, the bytecode is usually interpreted or compiled to native code for execution, although direct execution in hardware Java bytecode by a processor is also possible.

The implementation of original and reference compiler, the virtual machine and Java class libraries were developed by Sun Microsystems in 1995. Since then, Sun has controlled the specifications, development and evolution of language through the Java Community Process, although others have also developed alternative implementations of these technologies from Sun, some even under free software licenses.

Between November 2006 and May 2007, Sun Microsystems released most of its Java technologies licensed under the GNU GNU, according to the specifications of the Java Community Process, so that virtually the entire Sun’s Java is now free software ( although the class library Sun is required to run Java programs is not yet free software).

Java technology was created as a programming tool to be used in a draft set-top-box in a small operation called the Green Project at Sun Microsystems in 1991. The team (Green Team), composed of thirteen people and directed by James Gosling, he worked for 18 months on Sand Hill Road in Menlo Park in its development.

The language was originally called Oak (for an oak that was outside the office Gosling), then was renamed after discovering that Green Oak was already a registered trademark adapters for graphics cards and eventually renamed Java.

The term was coined Java in a cafe frequented by some of the team members. But it is unclear whether or not an acronym, although some sources indicate that this could be the initials of its creators: James Gosling, Arthur van Hoff, and Andy Bechtolsheim. Others argue for the following acronym, Just Another Acronym Vague ( “just another acronym more ambiguous”). The hypothesis that has more strength is that Java is named after a type of coffee available in the nearby cafeteria. A small sign that gives strength to this theory is that the first 4 bytes (the magic number) of archives. Class generated by the compiler, are in hexadecimal, 0xCAFEBABE. Others simply say the name was drawn to an apparently random list of words.

The objectives of Gosling were implementing a virtual machine and a language with a structure and syntax similar to C + +. Between June and July 1994, after a marathon three-day meeting between John Gage, James Gosling, Joy Naughton, Wayne Rosing and Eric Schmidt, the team refocused the platform toward the Web. They felt that the arrival of the Mosaic Web browser, Internet lead that would become an interactive medium, as they thought it was cable television. Naughton then created a prototype browser, WebRunner, which later became known as HotJava.

In 1994, they gave a demonstration of HotJava and the Java platform to Sun executives. 1.0a could download Java for the first time in 1994 but had to wait for the May 23, 1995, during the conferences of SunWorld, to see the public light Java and HotJava, the Web browser. The event was announced by John Gage, Chief Scientist of Sun Microsystems. The event was accompanied by a small additional surprise, the announcement by Marc Andreessen, executive vice president of Netscape, Java would be supported in their browsers. On January 9 next year, 1996, Sun founded the JavaSoft business group that is responsible for technological development. [1] Two weeks later the first version of Java was published.

The initial promise of Gosling was Write Once, Run Anywhere (Escríbelo once, run it anywhere), providing a platform independent language and an execution environment (the JVM) lightweight and free for the most popular platforms so that binaries (bytecode) from Java applications could run on any platform.

The execution environment was relatively safe and major web browsers soon incorporated the ability to run Java applets embedded in Web pages.

Java has undergone numerous changes since the original version, JDK 1.0 and a huge increase in the number of classes and packages that make up the standard library.

Since J2SE 1.4, the evolution of language has been regulated by the JCP (Java Community Process), which uses Java Specification Requests (JSRs) to propose and specify changes in the Java platform. The language itself is specified in the Java Language Specification (JLS), or Java Language Specification. Changes in JLS are managed in JSR 901.

* JDK 1.0 (January 23, 1996) – First launch.

press release

* JDK 1.1 (19 February 1997) – Key additions included: press release
or an intensive restructuring model events AWT (Abstract windowing Toolkit)
classes or internal (inner classes)
or JavaBeans
or JDBC (Java Database Connectivity), for integrating databases
or RMI (Remote Method Invocation)

* J2SE 1.2 (December 8, 1998) – Name key Playground. This and the following versions were listed under the name Java 2 and the name “J2SE (Java 2 Platform, Standard Edition), replaced JDK to distinguish the platform base j2ee (Java 2 Platform, Enterprise Edition) and J2ME (Java 2 Platform, Micro Edition). Other improvements include added: press release
or keyword (keyword) strictfp
or reflection in programming
or graphics API (Swing) was integrated into the core classes
or the virtual machine (JVM) Sun was equipped with a JIT compiler (Just in Time) for the first time
or Java Plug-in
IDL or Java, an implementation of IDL (Interface Description Language) for interoperability with Corban
Collections or (Collections)

* J2SE 1.3 (May 8, 2000) – Name key Kestrel.

The most notable changes were: press release full list of changes

*
or the inclusion of the JVM HotSpot Virtual Machine (JVM HotSpot was initially launched in April 1999 for the JVM J2SE 1.2)
or RMI was changed to be based on Corban
or JavaSound
or are included Java Naming and Directory Interface (JNDI) in the main pack bookstores (previously available as an extension)
or Java Platform Debugger Architecture (JPDA)

* J2SE 1.4 (6 February 2002) – Name Key Merlin. This was the first launch of the Java platform developed under the Java Community Process as JSR 59. The most notable changes were: communiqué prensalista comprehensive changes
Word or reserved assert (Specified in JSR 41.)
Regular expressions or modeled along the lines of Perl regular expressions
or chained exceptions allows an exception to encapsulate the original low-level exception.
or non-blocking NIO (New Input / Output) (Specified in JSR 51.)
Logging or API (JSR Specified in 47.)
API or I / O for reading and writing images in formats like JPEG or PNG
or XML Parser integrated and XSLT processor (JAXP) (Specified in JSR 5 and JSR 63.)
Integrated Security and extensions or cryptographic (JCE, JSSE, JAAS)
or Java Web Start included (The first launch occurred in March 2001 for J2SE 1.3) (Specified in JSR 56.)

* J2SE 5.0 (September 30, 2004) – Code Name: Tiger. (Originally numbered 1.5, this notation is still used internally. [2]) Developed under JSR 176, Tiger added a significant number of new features press release
Templates or (generic) – provides conversion rate (type safety) at compile time for collections and eliminates the need for conversion of most types (type casting). (Specified by JSR 14.)
or Metadata – also called annotations, enabling structures such as language classes or methods, be tagged with additional data, which can be further processed by utilities process metadata. (Specified by JSR 175.)
or autoboxing / Unboxing – automatic conversion between primitive types (such as int) and classes wrap primitive (As Integer). (Specified by JSR 201.)
or enumeration – the word reserved enum creates a typesafe, ordered list of values (as Dia.LUNES, Dia.MARTES, etc.).. Previously, this could only be carried out by constant entire classes or built manually (enum pattern). (Specified by JSR 201.)
or VarArgs (variable number of arguments) – The last parameter of a method can be declared under the name of the type followed by three dots (eg void drawText (String. lines ..)). In the call to the method can be used any number of such parameters, which will be stored in an array for passing the method.
or loop for improved – The syntax for the for loop has been extended with a special syntax to iterate on each member of an array or on any class that implements ITER, as the standard class Collection, as follows:

displayWidgets void (ITER <Widget> widgets) (
for (Widget w: widgets) (
w.display ();
)
)

This example iterated on property ITER widgets, assigning, in order, each element to the variable w, and calling the method display () each. (Specified by JSR 201.) |)

* Java SE 6 (December 11, 2006) – Name key Mustang. He was developing under the JSR 270. In this version, Sun changed the name “J2SE” Java SE and eliminated the “.0″ the version number. [3]. It is available in http://java.sun.com/javase/6/. The most important changes introduced in this release are:
or includes a new framework and APIs that make possible the combination of Java with dynamic languages like PHP, Python, Ruby and JavaScript.
It includes the engine or Rhino, Mozilla, an implementation of JavaScript in Java.
Includes a customer or complete Web services and supports the latest specifications for Web services, such as JAX-WS 2.0, JAXB 2.0, Stax and JAXP.
or improvements in the graphical interface and performance.

* Java SE 7 – Name Key Dolphin. The year 2006 was still in the early stages of planning. It is hoped that its development may begin in spring 2006, and its launch is estimated for 2008.
Support for XML or within one’s own language.
o A new concept of superpaquete.
Support for or closures.
Entering or endorsements standard for detecting flaws in the software.
* No official:
or NIO2
or Java System Module.
or Java Kernel.
or New API for handling Dias and dates, which replace the old classes Date and Calendar.
Ability to operate or classes BigDecimal using operands.

[4]

In addition to changes in the language, over the years have made many more dramatic changes in the Java class library (Java class library) that has grown from a few hundred classes in JDK 1.0 to more than three thousand in J2SE 5.0. APIs completely new, as Swing and Java2D, have been introduced and many of the methods and classes original JDK 1.0 is obsolete.

In 2005 is estimated at 4.5 million the number of developers and 2,500 million Java technology-enabled devices.

Between November 2006 and May 2007, Sun Microsystems released most of its Java technologies licensed under the GNU GNU, according to the specifications of the Java Community Process, so that virtually the entire Sun’s Java is now free software ( although the class library Sun is required to run Java programs is not yet free software).

Philosophy

The Java language was created with five main objectives:

1. Should I use the methodology of object-oriented programming.
2. It should allow the execution of the same program on multiple operating systems.
3. It should include default support for work in network.
4. It should be designed to execute code on remote systems safely.
5. It should be easy to use and make the best of other object-oriented languages, like C + +.

To achieve remote code execution and network support, Java developers sometimes resort to extensions as Corba (Common Object Request Broker Architecture), the Internet Communications Engine or OSGi respectively.

Object-Oriented

The first feature, object-oriented (OO), refers to a method of programming and design language. Although there are many interpretations for OO an initial idea is to design the software so that different types of data you use are linked to their operations. Thus, data and code (functions or methods) are combined into entities called objects. An object can be seen as a package containing the “behavior” (the code) and the “state” (data). The principle is to separate what changes things remain unchanged. Often, changing a data structure implies a change in the code that operates on them, or vice versa. This separation into objects consistent and independent offers a more stable basis for designing a system software. The aim is to make big projects are easy to administer and manage, as a consequence improve their quality and reducing the number of failed projects. Another of the great promise of object-oriented programming is creating more generic entities (objects) to reuse software between projects, one of the fundamental premises of the Software Engineering. An object generic “customer”, for example, should theoretically have the same set of behaviour in various projects, especially when they coincide to a certain extent, something that usually happens in large organizations. In this sense, the objects could be seen as reusable pieces that can be used in many different projects, thus enabling the software industry to build major projects using existing components and proven quality, it finally leading to a drastic reduction in the time development. We can use as an example of the aluminum object. Once defined data (weight, malleability, and so on.), And its “behavior” (welding two pieces, etc..), The object “aluminum” can be reused in the field of construction, automotive, aviation, etc. .

The reuse software has experienced mixed results, finding two major difficulties: the design of objects really generic is poorly understood, and lack a methodology for the broad communication opportunities for reuse. Some communities of “open source” (open source) want to help in this problem by giving developers a means to disseminate information on the use and versatility of reusable objects and libraries of objects.

Independence Platform

The second feature, regardless of platform, means that programs written in Java can run equally in any kind of hardware. It is what it means to be able to write a program once and it can run on any device, as the axiom says Java,” ‘write once, run everywhere”’.

This will compile the source code written in Java, to generate a code known as “bytecode” (specifically Java bytecode)-simplified machine instructions specific to the Java platform. This piece is “halfway” between the source and the code machine that understands the destination device. The bytecode is then executed in the virtual machine (VM), a program written in native code of the target platform (which is the one that understands your hardware), which interprets and executes the code. In addition, libraries are provided for additional access to the characteristics of each device (such as graphics, through execution threads or threads, network interface) in a unified manner. We must bear in mind that although there is an explicit stage of compilation, generated bytecode is interpreted or translated into machine code instructions by the compiler native JIT (Just In Time).

There are implementations of Java compiler that convert the source code directly into native object code, as GCJ. This eliminates the intermediate stage where it generates bytecode, but the departure of such compilers can only run on one type of architecture.

The license on Sun’s Java insists that all implementations are “compatible”. This led to a legal dispute between Microsoft and Sun, where the latter claimed that the implementation of Microsoft did not support the interfaces and RMI NYI well as added features”dependent”on your platform. Sun sued Microsoft and won for damages (about $ 20 million) as well as a court order forcing compliance with the license from Sun. In response, Microsoft offers no Java version of its operating system, and in recent versions of Windows, its Internet Explorer browser does not support the execution of applets without a connector (or plug) apart. However, Sun and other sources offer free versions for different versions of Windows.

The first implementations of the language used a virtual machine interpreted to achieve portability. However, the results were programs that were implemented comparatively slower than those written in C or C + +. This made Java won a reputation for slow performance. The recent implementations of the JVM lead to programs that run considerably faster than the old versions, using various techniques, although still much slower than other languages.

The first of these techniques is simply compile directly into native code compilers as do traditional, eliminating the stage of bytecode. This leads to a great performance in the execution, but the road to cover portability. Another technique, known as compilation JIT (Just In Time,”or ‘compilation on the fly”’), converts bytecode to native code when running the application. Other VMs use a more sophisticated” ‘dynamic recompilation”’ in which the VM is capable of analyzing the behavior of the running program and will rebuild and optimizes critical parts. The dynamic recompilation can achieve greater degree of optimization that the compilation traditional (or static), as it can base its work on knowledge that has first-hand about the environment and executing all classes loaded into memory. The JIT compilation and dynamic recompilation allow Java programs harness the speed performance of native code without losing the advantage of portability.

The portability is technically difficult to achieve, and the success of Java in this area has been mixed. While it is indeed possible to write programs for the Java platform to act correctly in multiple platforms of different architecture, the large number of those with minor errors or inconsistencies that sometimes carry the slogan was parodie Sun, “Write once, run anywhere “as” Write once, debug everywhere “(or” Escríbelo once, run it anywhere “with” Escríbelo once, depúralo everywhere “)

The concept of independence of the Java platform has, however, with great success in the applications on the server environment, such as Web services, servlets, Java Beans, as well as embedded systems based on OSGi, using environments Embedded Java.

The garbage collector

One argument against languages like C + + programmers is that they face the added burden of having to manage memory dynamically applied by hand:

In C + +, the developer can allocate memory in an area known as heap (mound) to create any object, and then vacate the space allotted when you want to delete it. An oblivion when it comes to evict previously requested memory can lead to a leak of memory, since the operating system will continue to believe that that area of memory is being used by an application when in fact it is not. Thus, a poorly designed program could consume a disproportionate amount of memory. In addition, if the same region of memory is evicted twice the program can become unstable and lead to an eventual crash. However, it should be noted that C + + also lets you create objects in the stack call a function or block, so as to release the memory (and run the destroyer of the object) automatically at the end of the performance of the function or block.

In Java, this potential problem is largely avoided by automatic garbage collector (or automatic garbage collector). The developer determines when objects are created and runtime Java (Java runtime) is responsible for managing the life cycle of objects. The program, or other objects may have located an object through a reference to it (which, from a low level is a memory address). When there are references to an object, the garbage collector Java clears the object, thus freeing the memory occupied by preventing leaks (example: an object created and used only within a method has only entity within it; to leave the object is removed method). Even so, it may produce memory leaks if the code stored references to objects that are no longer needed-that is, they can still happen, but at a higher conceptual level. Ultimately, the scavenger Java allows easy creation and disposal of objects, greater security and maybe faster than C + + [citation needed].

The garbage collection Java is a process virtually invisible to the developer. In other words, the developer has no conscience when garbage collection will take place, since it need not necessarily relate to actions carried out by the source.

It should be noted that the memory is only one of many resources to be managed.

Syntax

The syntax of Java is derived largely from C + +. But unlike the latter, which combines the syntax for generic programming, structured and object-oriented, Java was built from the outset to be completely object-oriented. Everything in Java is an object (with some exceptions), and all Java lies in some form (remember that one class is a mold where they can set up several objects).

Hello World
Main article: Hello world

Stand-alone application

/ / Hola.java
public class Hello
(
public static void main (String args) (
System.out.printf ( “Hello, world!”);
)
)

This example needs a little explanation.

* Any Java is within a class, including autonomous programmes.
* The source code is stored in files with the same name as the class containing and extension. “Java”. One class (class) declared public (public) must follow this convention. In the above example, the class is Hello, so that the source should be kept in the file “Hola.java”
* The compiler generates a class (with extension. “Class”) for each class defined in your source. An anonymous class is treated as if his name off the chain by the name of the class that holds the symbol “$”, and a whole number.
* Programs running as an independent and autonomous, must contain the “main ()”.
* The reserved word “void” indicates that the main method does not return anything.
* The main method must accept an array of objects type String. By agreement is referred to as “args”, but can be used any other identifier.
* The reserved word “static” indicates that the method is a method of class, associated with the class rather than at the behest of the same. The main method should be static or”class”.
* The keyword public means that a method can be called from other classes, or that class can be used by classes outside the hierarchy of the class itself. Other types of access are “private” or “protected”.
* The value of printing (screen for example) is part of the standard Java: Class” ‘System”’ defines a public static field called” ‘out”’. The object is an instance of out” ‘printstream”’ offered by the method” ‘println (String)”’ to dump data on the screen (output).
* The stand-alone applications are executed giving the Java Runtime Environment on behalf of the class whose main method should be invoked. For example, a command line (on Unix or Windows) as java-cp. Hello implement the programme of example (previously compiled and generated “Hola.class”). The name of the class whose main method is called can be specified in the file “MANIFEST” file packaging Java (. Jar).

Applets

The Java applets are programs embedded in other applications, typically a Web page that is displayed in a browser.

/ / Hola.java
import java.applet. Applet;
import java.awt. Graphics;

public class Hello extends Applet (
public void paint (Graphics gc) (
gc.drawString ( “Hello, world!”, 65, 95);
)
)

<! – Hola.html ->
<html>
<head>
<title> applet Hello World </ title>
</ head>
<body>
<applet code=”Hola” width=”200″ height=”200″>
</ applet>
</ body>
</ html>

The judgement import tells the Java compiler that includes classes java.applet. Applet and java.awt. Graphics, to be able referenced by their names, without having to put the full path every time you want to use the source code.

The class extends Hello (extends) to the class applet, that is, is a subclass of it. The class applet allows the application display and monitor the state of applet. The class applet is a component of AWT (Abstract windowing Toolkit), which allows the applet inteterfaz display a graphical user or GUI (Graphical User Interface), and responding to events generated by the user.

The class Hello overload the method paint (Graphics) inherited from the superclass container (applet in this case), to enter the code responsible for drawing. The method paint () receives a Graphics object that contains the context graph to draw the applet. The method paint () calls the method drawString (String, int, int) Graphics object to display the string Hello, world! in the position (65, 96) drawing of space allocated to the applet.

The reference to the applet is placed in an HTML document using the label <applet>. This label or tag has three attributes: code = “Hello” indicates the name of the applet, and width = “200″ height = “200″ sets the width and height, respectively applet. An applet can also stay within an HTML document using the elements object, or embed, although the support offered by Web browsers is not uniform. [5] [6]

Servlets

The servlets are components of the server part of Java EE, responsible for generating responses to requests received from customers.

/ / Hola.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”);
PrintWriter pw = response.getWriter ();
pw.println ( “Hello, world!”);
pw.close ();
)
)

Sentences import Java compiler to indicate the inclusion of all public classes and interfaces javax.servlet package java.io and in the compilation.

The class extends Hello (extends), is heir to the class GenericServlet. This class provides the interface to the server it passes requests to servlet and the mechanism for controlling the life cycle servlet.

The class Hello overload the method service (ServletRequest, ServletResponse), defined by the servlet interface to access the driver of the request for service. The method service () receives an object type ServletRequest containing the request of the client and a ServletResponse object type, used to generate the response that is returned to the customer. The method service () can throw (throws) and exceptions type ServletException IOException happens if some kind of anomaly.

The method setContentType (String) in response object provides the type of content to mime “text / html”, to tell the customer that the answer to your request is a page with HTML format. The method getWriter () Object response returns an object of type PrintWriter, used as a pipeline for which data will travel to the customer. The method println (String) writes the string “Hello, world!” in response and finally close the method is called () to close the connection, which makes data written in the pipe or stream are returned to the customer.

Windowed applications

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

/ / Hola.java
import javax.swing .*;

public class Hello extends JFrame (
Hello () (
setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
add (new JLabel ( “Hello, world !”));
Pack ();
)

public static void main (String args) (
Hello new (). setVisible (true);
)
)

The instructions tell the compiler import Java classes and interfaces that the package javax.swing be included in the compilation.

The class extends Hello (extends) javax.swing.JFrame class, which implements a window with a title bar and control to close it.