Java Basics

From JumbaWiki

Jump to: navigation, search

A Java application is typically made up of libraries, packages and classes which are usually compiled into Jar files. There can be many other components of a Java application but these are probably not approriate for a basic overview.

Contents

Jar Files

A Jar file (Java ARchive) is simply a zipped archive of classes and other resources (sounds, images etc) of a library or application. A Jar file is usually created using the 'jar' application that comes with the Java development toolkit.

Libraries

A library is a collection of classes that can be included in a Java application to provide certain functionality. Sometimes a library provides visual components, sometimes it provides programmatic functionality for your application.

Every Java application has access to the main Java libraries known as the JRE (Java Runtime Environment) System Libraries, which provide all sorts of functionality to your applications such as GUI (Graphic User Interfaces), Math, Strings, Databases, Cryptography, Graphics etc.

It is important to know that Java is typically available in 3 version J2SE (Java 2 Standard Edition), J2EE (Java 2 Enterprise Edition) and J2ME (Java 2 Micro Edition). The edition of Java being used will dictate which System Libraries are available.

Packages

A Java application may use many libraries that were created by many different developers - this is where packages come in.

Packages are used to organise classes and prevent naming conflicts when developers use the same class name. The Java application will refer to classes via the package name which prevents the conflict.

To prevent package names from being duplicated, developers are encouraged to use their domain name as part of the package name ie:

 com.example.package.name

Classes

Classes are the blocks of code that define the states, properties and behaviours of objects within a Java application. When a class is used in a Java application, it is referred to as being an instance of that class.

In an OO (Object Oriented) language like Java, classes are typically used as the blue-print for similar objects that share some similar characteristics. When a class is built upon the blue-prints of a similar class it is called inheritance, as the new class inherits the behaviours of the original class (and add it's own unique behaviours and properties).

It is important to remember that class properties or variables are shared between all instances of the class, while instance properties (set at runtime) are only applicable to that object or instance of the class and are not shared.

War Files

A WAR or Web application ARchive file is a type of Jar file that follows certain conventions on where resources are placed. This allows a Java application server like Tomcat to deploy a complete web application with no extra configuration.

See also

Code Basics
ActionScript | ASP | ASP.NET | CGI | ColdFusion | CSS | HTML | Java | JavaScript | JSP | MySQL | Perl | PHP | XML | XHTML
Personal tools
Australian Photography | Unique Views of Reality | Daedalus