Archive

Posts Tagged ‘jvm’

Developing & Testing a program in Java

November 6, 2009 Leave a comment

 

 

Module 3: Developing & Testing a Java Technology program.

 

Objectives:

1. Identify  4 components of class.
2. Use main method in a test class to run a java program from command line.
3. Compile & execute a java program.

 

1. Identify  4 components of class:

Going back to what we discussed before about classes, to construct a house you will first need a blueprint. Same thing applies for classes & objects. Similarly once you have a class blueprint, you  can have as many objects of that class as u like. These objects are called instances of a class. i.e., a shirt object is an instance of a shirt class.

 

27. class and its objs

 

Lets take a look at our first class:

Class is a blueprint that tells the computer how to make objects. This class blueprint – Shirt, tells the computer how to make Shirt objects.

 

28. 1st class

 

 

Structuring classes:

There are 4 major components of class that you will find more often:

  • class declaration – required
  • attribute variable declaration & initialization – optional
  • methods – optional
  • comments – optional

1. Class declaration is required, and this is all that you need to make a class valid. If all you had was this, then the class and its objects would be uninteresting serving no purpose. You will be needing some attributes and operations to jazz up the object.

2. Variables are characterstics of your objects. As we discussed in previous posts, these are characterstics /  properties and they are also data holders. They hold the data for the object.

3. In this Shirt class, only one method is defined. Methods are operations. They tell the class what to do.  Its what the class can do.  This method is printing all its information to the command window.

4. Comments are for developers to understand what the code is doing, they dont influence the execution in anyway.

 

Class declaration: Read more…

Explaining Java Technology

November 6, 2009 Leave a comment

  

Module 1 – Explaining Java Technology.

 

Objective:

Upon completion of reading this post, you should be able to know:

  • Key concepts of Java programming language.
  • Three Java technology product groups.
  • Seven stages of product life cycle.

 

 

Key concepts of Java programming language:

Java programming language originated in Sun Microsystems in 1999 as part of a research project to develop a programming language calld oak that would bridge the communication gap between many consumer devices such as video casette recorders & TV. Specifically, a team called green team wanted to create a software programming language enabling consumer devices with different CPU to share same software enhnacements.

 

 

1. green team

 

Initial concept failed as several deals with consumer companies were unsuccessful. So green team had to find another market. At that time www was becoming popular, and green team recognized tht the Oak language was perfect for developing web multimedia components to enhance web pages. Initially, small programs called applets became extensively used and gradually internet developers adopted what now is known as Java.

2. green team with internet

 

 

Java was designed to be: Read more…

Java Terminologies

September 6, 2009 Leave a comment

 

Few terminologies to be familiar with, before getting started with Java:

 

Java Platform:

The Java platform from Sun allows developing and running programs written in the Java programming language. The platform is not specific to any one processor or operating system, but rather an execution engine called virtual machine and a compiler with a set of standard libraries that are implemented for various hardware and operating systems so that Java programs can run identically on all of them.

The Java Platform consists of several programs, each of which provides a distinct portion of its overall capabilities. For example, the Java compiler converts Java source code into Java byte-code, an intermediate language to be executed by the virtual machine (JVM) and it is provided as part of the Java Development Kit (JDK). The Java Runtime Environment (JRE), complementing the JVM with a just-in-time (JIT) compiler, converts intermediate byte-code into native machine code on the fly. Also supplied are extensive libraries, pre-compiled in which are several other components, some available only in certain versions.

The essential components in the platform are the Java language compiler, the libraries, java language itself (Java API) and the runtime environment in which Java intermediate byte-code “executes” according to the rules laid out in the virtual machine specification. 

  Java Platform

JVM:

The heart of the Java Platform is the concept of a “virtual machine” that executes Java byte-code. This byte-code is the same no matter what hardware or operating system the program is running under. The use of byte-code as an intermediate language permits Java programs to run on any platform that has a virtual machine available. Although Java programs are platform independent, the code of the Java Virtual Machine (JVM) that execute these programs is not so every supported operating platform has its own JVM.

The JVM is a crucial component of the Java Platform. It is a platform-independent execution environment that converts Java byte-code into machine language and executes it. Most programming languages compile source code directly into machine code that is designed to run on a specific microprocessor architecture or operating system, such as Windows or UNIX.

The JVM is an instance of the JRE (Java Runtime Environment) and comes into action when a Java program is executed. JVM can be obtained with JRE / JDK distribution.

Few functionalities of JVM are:-

  • Loading of class files (compiled java source code).
  • Verification of class files i.e., Class files should contain valid byte-code.
  • Interpretation of byte code and then run the program. 

  

JIT: Read more…