Java Tutorials

Basic Cocept of Terms used in Programming

posted Aug 9, 2011, 8:29 AM by Govind Sharma

Tokens:  Smallest individual units in a program are known  as tokens. The compiler recognizes them for building up expressions and statements. Java program is a collection of tokens, comments and white spaces. Java language include five types of tokens. They are:

Reserved keywords





Java Character Set : The smallest units of Java Language are the characters used to write Java Tokens. These characters are defined by the Unicode character set. The Unicode is a 16 bit character coding system and currently supports more than 34000 defined characters derived from 24 languages.

Keywords : are an essential part of a language definition.These are the some word which java uses for its syntax definition. Java language has reserved about 50 words or keywords.

Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.





















































not used



added in 1.2



added in 1.4



added in 5.0

Identifiers:Identifiers are programmer designed tokens. They are used for naming classes methods, variables,object, labels, packages, and interface in a program. Java identifiers follow the following rules:

1) They can have alphabets, digits, and the underscore and dollar sign characters.

2) They must not begin with a digit.

3) Uppercase and lowercase letters are distinct.

4) They can be of any length.

Compiling and Running the java program

posted Aug 4, 2011, 8:39 AM by Govind Sharma

Illustration with simple program for compiling and running the java program.

Step 1: Creating the Program

 Open the notepad  and write the program, save the program "" ensuring that the file name contains the class name properly. This file is called source file.

If a program contains multiple classes, the file name must be the classname of the class containing the main method

class Test


      public static void main ( String args[])


             System.out.println("Welcome to the world of Java. ");



Step 2: To compile the type in command prompt


javac is java compiler. If everything is OK, then javac compiler creates a file called Test.class containing the bytecode of the program.

Step 3: After compiling to run the program, we need to use the java interpreter to run the program, At the command prompt, type

                                               java Test

Now, the interpreter looks for the main method in the program and begins execution from there.


 Welcome to the world of Java.

Secret of Java Machine neutral or platform independent.

posted Aug 4, 2011, 8:14 AM by Govind Sharma

Java The Machine Neutral or Platform Independent programming language.

1 ) What does Machine Neutral or Platform Independent means ?

 Machine Neutral Platform Independent means that while writing the program in java, we don't need to care about on which Machine or platform the program will going to be executed. Like in C language if we want to run the program in Windows XP the we need to write the program in windows compatible C compiler and in windows platform to c program  in UNIX or Linux  we need to edit and compile the same program in Linux and UNIX compatible compiler and environment . Same in visual basic program can only run in Windows platform.

Java breaks all these restriction, Java gives the freedom to write and compile the program in any platform or machine and the same program can run on different platform and machine. Example Java program written for Linux system can also run on windows and UNIX etc.

2) How Java do this?

The secret behind platform independent of java is JAVA VIRTUAL MACHINE.

All language compilers translate source code into machine code for a specific computer. Java compiler also does the same thing. Then, how does java achieve architecture neutrality? The answer is that the Java compiler produces an itermedia code known as bytecode for  a machine that does not exits. This machine is called the Java Virtual Machine and it exits only inside the computer memory. It is a simulated computer within the computer and does all major functions of a real computer.


Java SE 6 Release Notes Microsoft Windows Installation (32-bit)

posted Aug 4, 2011, 8:11 AM by Govind Sharma

Java SE 6 Release Notes
Microsoft Windows Installation (32-bit)


JDK Documentation

System Requirements

See supported System Configurations for information about supported platforms, operating systems, desktop managers, and browsers.

The minimum physical RAM is required to run graphically based applications. More RAM is recommended for applets running within a browser using the Java Plugin. Running with less memory may cause disk swapping which has a severe effect on performance. Very large programs may require more RAM for adequate performance.

This installation requires Windows Installer 2.0 to be on your machine. For more details, see the Troubleshooting the Installation section .

For the amount of disk space required, see Windows Disk Space Requirements.

Note - The JDK has two version numbers -- external version number (6) and an internal version number (1.6.0).

Note - Trying to install the JDK on a non-supported version of Microsoft Windows or on a machine that doesn't have a sufficiently up-to-date Service Pack will cause the installer to generate this warning: "We recommend that you do not install this Java platform for the following reasons: This Java platform does not support the operating system or operating-system service pack on this machine." See the system requirements above for information on supported configurations of Microsoft Windows.

Installation Instructions

In this procedure, you will run the self-installing executable to unpack and install the JDK software bundle. As part of the JDK, this installation includes an option to include the public Java Runtime Environment. (The JDK also contains a private JRE for use only by its tools.)

For issues related to Windows Online Installation and Java Update, see the Windows Online Installation and Java Update FAQ. See this note on Proxy Settings and Authentication.

Troubleshooting - If you have any difficulties, see the Troubleshooting section at the end of this document or submit a bug report for your installation problem.

Note - For any text on this page containing the following notation, you must substitute the appropriate update version number for the notation.


For example, if you were downloading the installer for update 1.6.0_01, the following file name:


would become:


1. Check the download file size (Optional)

If you save the self-installing executable to disk without running it from the download page at the web site, notice that its byte size is provided on the download page. Once the download has completed, check that you have downloaded the full, uncorrupted software file.

2. Run the JDK installer

You must have administrative permissions in order to install the JDK on Microsoft Windows.

The file jdk-6u1<version>-windows-i586-i.exe is the JDK installer. If you downloaded it instead of running it directly from the web site, double-click on the installer's icon. Then follow the instructions the installer provides. The installer may ask you to reboot your computer. When done with the installation, you can delete the download file to recover disk space.

Installed Directory Tree

The JDK has the directory structure shown below.

The JDK has the option of installing public JRE and JavaDB. For more information on JRE installation see the JRE Installation page.

JDK Silent Installation

You can perform a silent JDK installation by using the command-line arguments. The following arguments install JDK silently and provide an option of installing public JRE and JavaDB.

  • JDK installs public jre and javadb in the silent mode.
    Use the command jdk.exe /s
  • JDK does not install public jre, but installs javadb in the silent mode.
    Use the command jdk.exe /s ADDLOCAL="ToolsFeature,DemosFeature,SourceFeature,JavaDBFeature"
  • JDK does not install javadb, but installs public jre in the silent mode.
    Use the command jdk.exe /s ADDLOCAL="ToolsFeature,DemosFeature,SourceFeature,PublicjreFeature"
  • JDK does not install either javadb or public jre in the silent mode.
    Use the command jdk.exe /s ADDLOCAL="ToolsFeature,DemosFeature,SourceFeature"
  • Install public jre and javadb to the specified directories.
    Use the command jdk.exe /s /INSTALLDIRPUBJRE=c:\test\ /INSTALLDIRJAVADB=c:\testdb\

Note - Some of the arguments work only with 6u15 and higher releases.

3. If you want to run Netscape 7.x, Mozilla 1.x, or Firefox 1.x with Java Plugin, do this:

  • Exit the Netscape 7.x, Mozilla 1.x, or Firefox 1.x browser and all of its "objects" (Messenger, Composer ...);
  • If the Quick Launch feature is enabled, disable it;
  • Then restart Netscape 7.x, Mozilla 1.x, or Firefox 1.x.

4. Update the PATH variable (Optional)

You can run the JDK without setting the PATH variable, or you can optionally set it as a convenience. Should I set the PATH variable?

Set the PATH variable if you want to be able to conveniently run the JDK executables (javac.exe, java.exe, javadoc.exe, etc.) from any directory without having to type the full path of the command. If you don't set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

C:> "\Program Files\Java\jdk1.6.0_<version>\bin\javac"

It's useful to set the PATH permanently so it will persist after rebooting. How do I set the PATH permanently?

To set the PATH permanently, add the full path of the jdk1.6.0_<version>\bin directory to the PATH variable. Typically this full path looks something like C:\Program Files\Java\jdk1.6.0_<version>\bin. Set the PATH as follows on Microsoft Windows:

  1. Click Start > Control Panel > System on Windows XP or Start > Settings > Control Panel > System on Windows 2000.
  2. Click Advanced > Environment Variables.
  3. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for PATH is:
    C:\Program Files\Java\jdk1.6.0_<version>\bin
  • PATH environment variable is a series of directories separated by semi-colons (;) and is not case sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.
  • You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored. If one is already present, update it to jdk1.6.0_<version>\bin.
  • If you are not sure where to add the path, add it to the right end of the PATH in the User Variables.
  • The new path takes effect in each new command window you open after setting the PATH variable.


5. Start using the JDK!

Your computer system should now be ready to use the JDK. In this step, you'll run some simple commands to make sure it is working properly. If you are new to developing and running programs in the Java programming language, see The Java Tutorial online for some guidance. Note especially the tutorial trails under the heading Trails Covering the Basics.

You can also download the JDK documentation from the JDK download page.

Uninstalling the JDK

If you should ever want to uninstall the JDK, use the "Add/Remove Programs" utility in the Microsoft Windows Control Panel.

Location of VM Library Files (jvm.dll)

If you use the Invocation API to launch an application directly rather than using the Java application launcher, be sure to use the correct paths to invoke the Java HotSpot Client Virtual Machine (VM) or Java HotSpot Server VM, as desired. The path within the JDK to the Java HotSpot Client VM is:

jre/bin/client/jvm.dll (on x86)

The path to the Java HotSpot Server VM is:

jre/bin/server/jvm.dll (on x86)

jre/bin/server/jvm.dll (on IA64)

The corresponding locations in the Java SE Runtime Environment begin with jre1.6.0 instead of jre. The Exact VM and Classic VM are no longer part of the JDK, and existing code that uses the Invocation API to launch an application based on old paths to the Exact or Classic VMs will not work.

Troubleshooting the Installation

Below are some tips for working around problems that are sometimes seen during or following an installation. For more troubleshooting information, see the Java FAQ.

  • If you see the error message "config.nt. The system file is not suitable for running MS-DOS and Microsoft Windows Applications. " when you try to launch the installer on Microsoft Windows 2000 then there is a problem with the %SystemRoot%\System32\COMMAND.COM file To resolve the error see the article at

  • If you see the error message "corrupt cabinet file" then the file you have downloaded is corrupted. Check the file size against the expected file size listed in these instructions. If they don't match, try downloading the bundle again. A cabinet file contains compressed application, data, resource and DLL files.

  • If you see the error message "System Error during Decompression" then you might not have enough space on the disk that contains your TEMP directory.

  • If you see the error message " This program cannot be run in DOS mode." then do the following:
    1. Open the MS-DOS shell or Command Prompt window
    2. Right-click on the title bar
    3. Select Properties
    4. Choose the Program tab
    5. Push the Advanced button
    6. Make sure the item "Prevent MS-DOS-based programs from detecting Windows" is unchecked
    7. Select OK
    8. Select OK again
    9. Exit the MS-DOS shell
    10. Restart your computer.
  • Private vs. public JRE - Installing the JDK installs a private Java SE Runtime Environment (JRE) and optionally a public copy. The private JRE is required to run the tools included with the JDK. It has no registry settings and is contained entirely in a jre directory (typically at C:\Program Files\jdk1.6.0\jre) whose location is known only to the JDK. On the other hand, the public JRE can be used by other Java applications, is contained outside the JDK (typically at C:\Program Files\Java\jre1.6.0), is registered with the Windows registry (at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft), can be removed using Add/Remove Programs, might or might not be registered with browsers, and might or might not have java.exe copied to the Windows system directory (making it the default system Java platform or not).
  • Creating source files in Notepad - In Microsoft Windows, when you create a new file in Microsoft Notepad and then save it for the first time, Notepad normally adds the .txt extension to the filename. Therefore, a file you name is saved as It's important to note that you cannot see the .txt extension unless you turn on the viewing of file extensions (in Microsoft Windows Explorer, uncheck "Hide file extensions for known file types" under Folder Options). To prevent the .txt extension, enclose the filename in quotation marks, such as "", when typing it into the Save As dialog box. On the other hand, Microsoft WordPad does not add a file extension if you provide one -- you must save the file as "Text Document".
  • Choosing an installation path containing characters that are not part of the system code page - On Windows 2000, XP, and 2003, it is possible to name directories using characters that are not part of the system locale's code page. If such a directory is part of the installation path, then generic error 1722 occurs, and installation is not completed. Error 1722 is an Install Shield error code. It indicates that the installation process has failed. The exact reason for this error is not known at this time. To prevent this problem, make sure that the user and system locales are identical, and that the installation path only contains characters that are part of the system locale's code page. User and system locales can be set in the Regional Options or Regional Settings control panel.

Overview of Java Language

posted Aug 4, 2011, 8:09 AM by Govind Sharma

Java is general purpose, object oriented programming language. We can develop two types of java programs:

1)    Stand-alone applications.

2)    Web applets.

Stand-alone applications are programs written in java to carry out certain tasks on a stand-alone local computer.

Executing a stand-alone java program involves two steps:

    1) Compiling source code into bytecode using javac compiler.

    2) Executing the bytecode program using java interpreter.

Applets are small java programs developed for Internet applications. An applet located on a distant computer(server) can be downloaded via internet and executed on a local computer using a Java-capable browser.

Stand-alone programs can read write files and perform certain operations that applets cannot do. An applet can only run within a Web browser.

Java Program Structure


Documentation Section                              <----------------- optional


Package Statement                                    <----------------- optional


Import Statements                                     <----------------- optional


Interface Statements                                  <----------------- optional


Class definitions                                        <------------------ optional


Main Method Class


 Main Method definition                            <--------------------Essential



Documentation Section:-

This section a set of comment lines giving the name of the program, the author and other details, which the programmer would like to refer to refer to at a later stage.

Package Statement :- 

The statement declares a package name and informs the compiler that the classes defined here belong to this package.To continue java program package will be discussed more later on.

Import Statements :-

This statement is similar to the #include statement in C. Ex:- " import student.test;"                                                This statement instruct the interpreter to load the test class contained in the package student. Using import statement , We can have access to classes that are part of other named packages.

Interface Statement :-

An interface is like a class but includes a group of method declarations. This is optional section and is used only when we wish to implement the multiple inheritance features in program.To continue java program interface will be discussed more later on.

Class Definitions :-

A java program may contains multiple class definitions. Class are the primary essential elements of a java program. The number of classes used depends on the complexity of the problem.

Main Method Class :-

Since java program may contains multiple classes, So  Main class is one among them which has a main method that act as a starting point for the program or simple the main method drive the whole program.

The main method creates objects of various classes and establishes communications between them. On reaching the end of main, the program terminates and the control passes back to the operating system.

A simple Java Program may contain only main class and main method. It necessary to have a main method class in java program to run.


1 )Introduction to Java and its features.

posted Aug 2, 2011, 9:52 PM by Govind Sharma   [ updated Aug 4, 2011, 8:27 AM ]

Introduction to java and features of java

Java is one of the most job seeking programming language in the recent I.T industry. Object-Oriented Programming(OOP) is an approach to program organization and development, which attempts to eliminate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several new concepts. It is a new way of organizing and developing programs and has nothing to do with any particular language.
Java Features:
Compiled and Interpredted: Mostly a computer programming language is either compiled or interpreted. Java combines both these approaches thus making Java a two-stage system. First, Java compiler translates source code into what is known as bytecode instructions. Bytecodes are not machine instruction and therefore in the second stage, Java interpreter generates machine code that can be directly executed by the machine that is running the java program.
Platform-Independent and Portable:Java programs can be easily moved from one computer system to another, anywhere and anytime.changes and upgrades in operating systems, processors and system resources will not force any changes in java programs.
Java ensures portability in two ways. First, Java compiler generates bytecode instruction that can be implemented on any machine. Secondly, the size of the primitive data types are machine independent.
Object-Oriented: Java is a true object-oriented language. Almost everything in java is an object. All program code and data reside within objects and classes. Java comes with an extensive set of classes, arranged in packages.
Robust and secure: Java is a robust language. It provides many safeguards to ensure reliable code. It has strict compile time and run time checking for data types. It is designed as a garbage-collected language relieving the programmers virtually all memory management problems. Java also incorporates the concepts of exception handling which captures series errors and eliminates any risk of crashing the system.
Java systems not only verify all memory access but also ensure that no viruses are communicated with an applet. The absence of pointers in java ensures that programs cannot gain access to memory locations without proper authorization.
Distributed: java is designed as a distributed language for creating applications on networks. It has the ability to share both data and programs. Java applications can open and access remote objects on Internet as easily as they can do in local system.
This enables multiple programmers at multiple remote locations to collaborate and work together on a single project.
Multithreaded : Multithreaded means handling multiple tasks simultaneously. Java supports multithreaded programming. This means that we not wait for the application to finish one task before beginning another.

1-6 of 6