Tuesday, 29 October 2013

Java applet


A Java Applet is a java program that can be embedded in a html. An Applet is a “.class” that is precompiled. A applet is embedded in a html file using “applet” tag. Applets are the one of the main reason behind the success of java programming language.

A JVM must be installed on the client machine to run the applet. Also a java plug-in is required to be installed in the web browser. Now a day’s most browser support applets. Applets are designed to run on a client machine remotely. A applet can also run offline once downloaded.

Applets can run on any platform, it means they are platform independent. As applets are run remotely they have lot of restrictions. A applet is run in a sandbox environment in a browser. It means the applet cannot access the clients file system. Applet can have full access to the client machine if the user allows.

Applet can be run on all versions of java plug-in. Applets are used to make websites more dynamic and attractive. Applets support most of java controls like buttons, checkbox, text fields etc. Applets are widely used for creating interactive learning environment. Lot of games are also build using applets that also supports multiplayer gaming option.

Applets also support 3D graphics. It uses the system’s 3D hardware acceleration. It enables to develop applets with heavy graphics.

The main disadvantage of a java applet is it need the java plug-in installed in the browser. The mobile browsers are not capable to run applets. A applet code can also raise main security issues if its downloaded from a un-trusted source. A similar interface can be created in HTML very easily with less security issues and more compatibility.

Overall applet is one of the useful feature provided by java programming language to create dynamic and interactive websites.

Java virtual machine


Java Virtual Machine also known as JVM is a virtual machine that is included in Java Runtime Environment to run java applications. JVM can also be called as the heart of Java platform. If you have JRE installed on your computer or any device it means you have JVM installed in it.

The JVM is acts like a virtual environment to run platform independent java byte codes. Byte codes are the files with “.class” extension that are generated after compilation of java file. Byte codes are the intermediate code between java and machine language. JVM provides a cross platform functionality to java applications. Most programming languages like C complied the programs according to the operating system and processor architecture, it means they cannot run on machines having different processor architecture.

The JVM is a machine within original machine that acts as intermediate between the application and the original machine. The JVM converts the byte code files according to the original machine requirement. Hence java applications are platform independent as the JVM take care of all the platform dependencies.

JVM also runs the “.jar” files that are Java Archive files.

Java API is also bundled with JVM in Java Runtime Environment. The JVM is responsible for “write once run anywhere” (WORA) nature of java programs.

JVM also have lots of other feature like automated exception handling, memory management, garbage collection.

Java runtime environment


Java Runtime Environment (JRE) is included in JDK. It is one of the main part of a JDK to run java applications. It is a minimum requirement to run any java application.

Java Runtime Environment consists of Java Virtual Machine (JVM), various core classes, libraries and various other components to run java programs and applets. JRE plug-in is installed in every browser to run java applets and to deploy Java Web Start.

Java Web Start is used to deploy individual application over the network.
Java Runtime Environment is a sub-set of JDK and it is can also be downloaded separately. JRE is required on all operating systems to run java applications. It is also present on mobile devices which are capable of running java applications.

Java Runtime Environment is the very basic requirement to run java programs. It loads and runs java applications with the use of JVM.

When a java file is complied it generates a byte code file i.e. “.class” file. The byte code file is platform independent but the Java Runtime Environment is platform dependent. It means if you need to run java programs on Linux, you need a JRE for Linux. JRE is present for most of the operating system.

Hence java programs are platform independent but Java Runtime Environment is platform dependent means different platform have different JRE.

3 main types of java applications

There are 3 main types of java applications,
  1. Desktop application
  2. Web based application
  3. Applets

Desktop applications

Desktop applications are standalone programs that are installed on local computer. These programs mostly use local available resources on a computer. Some of the desktop application programs also make use internet for networking.

Web based application
Web based applications are programs that are accessed over a network i.e. internet or intranet. These applications are present on a centralized web server. Web based applications are accessed through web browser. These applications are based on client-server architecture. Web based applications are easy to maintain as they are not installed on different computers so updating is easy.
Applets
Applets are programs that can be embedded in a web page just like a image. They are delivered to a user as java bytecode and are executed by the browser’s JVM. Applets were introduced in the first version of Java. Applets is one of the most popular technology in Java. Applets are embedded in web page using embed tag.
Difference between desktop application, web based application and applet,
Desktop Application
Web Based Application
Applet
Installed on local computer

Stored on web server
Stored on web server and expected on clients web browser’s JVM
Need your laptop or desktop to install
Can be accessed from anywhere on any desktop
Can be accessed from anywhere on any desktop
User have to updated the application
Updated by website owner
Updated by website owner
Platform dependent
Platform independent
Platform independent just require JVM
High Piracy risk
No piracy risk
Very low piracy risk

What is Java?


During the early nineties, Java was developed by a group guided by James Gosling meant for Sun Microsystems. It had been earlier created to work on digital cellular devices, for example mobile phones. But, as soon as Java 1. 0 was released for the open public in 1996, its major aim had moved to implement on the Internet. It delivered much more interactivity with users by providing programmers a method to create animated webpages. Over time it has developed in the form of powerful language designed to work with both on and off the Internet. A decade soon after, it’s even now a remarkably popular language along with more than 6. 5million programmers all over the world.

Java is one of the most powerful programming language used these days. It is largely used for creating enterprise applications. A java program is written one and then it can be executed on any platform and any device having java run-time environment installed on it. A java program is mainly run in JRE.

When Java was first released, it mainly was comprised of 2 components: the actual programming language standards, along with the Java runtime environment specification which usually described the actual things about the JVM. As the Java language improved gradually, Sun Microsystems step by step included new features and also technologies which made Java a lot more than just a programming language. To illustrate, Servlets along with JavaServer Pages were created to offer a good mechanism designed for using Java to develop powerful Webpages. JavaBeans offer Java application component architecture. Enterprise JavaBeans gives a mechanism for the purpose of creating distributed applications. All of these technological innovations offer unique standards. Shortly after the introduction of Java 2, to develop standard runtime environments for Java programmers to focus on, Sun grouped their key Java programming technologies into 3 editions:

  • J2ME: Java 2 Platform, Micro Edition
  • J2SE: Java 2 Platform, Standard Edition
  • J2EE: Java 2 Platform, Enterprise Edition

J2SE

J2SE is the core programming language. It provides environment for developing java applications and also supports JDBC, applets, JavaBeans, RMI (Remote Method Invocation), networking, XML, GUI programming and lots of other technologies.

J2EE

J2EE is the enterprise version of java. It is a collection of java technologies for creating platform for distributed applications. J2EE provides support for creating large business applications with platform independency. It comprise of various enterprise technologies like Enterprise JavaBeans (EJB), Java Servlets, Java Server Pages, Java Mail, Java Messaging Services (JMS), Java Database Connectivity (JDBC), Java Naming and Directory Interface (JNDI), Extensible Markup Language (XML), Java Web Services, Java Transaction API (JTA), Java Transaction Service (JTS), etc.

J2ME

J2ME is Micro edition of java. It is not a scaled down version of java. It is mainly used for creating applications for portable devices like mobile phones.

This is just a short introduction of java. If you have any questions please do comment.