INTRODUCTION

1

INTRODUCTION TO JAVA
Java is a programming language originally developed by Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun made available most of their Java technologies as free software under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Classpath. History James Gosling initiated the Java language project in June 1991 for use in one of his many set-top box projects.[4] The language, initially called Oak after an oak tree that stood outside Gosling's office, also went by the name Green and ended up later renamed as Java, from a list of random words.[5] Gosling aimed to implement a virtual machine and a language that had a familiar C/C++ style of notation.[6] Sun released the first public implementation as Java 1.0 in 1995. It promised "Write Once, Run Anywhere" (WORA), providing no-cost run-times on popular platforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run secure Java applets within web pages, and Java quickly became popular. With the advent of Java 2 (released initially as J2SE 1.2 in December 1998), new versions had multiple configurations built

2

for different types of platforms. For example, J2EE targeted enterprise applications and the greatly stripped-down version J2ME for mobile applications. J2SE designated the Standard Edition. In 2006, for marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and Java SE, respectively. In 1997, Sun Microsystems approached the ISO/IEC JTC1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process.[7] Java remains a de facto standard, controlled through the Java Community Process.[8] At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java through the selling of licenses for specialized products such as the Java Enterprise System. Sun distinguishes between its Software Development Kit (SDK) and Runtime Environment (JRE) (a subset of the SDK); the primary distinction involves the JRE's lack of the compiler, utility programs, and many necessary header files. On 13 November 2006, Sun released much of Java as free and open source software under the terms of the GNU General Public License (GPL). On 8 May 2007 Sun finished the process, making all of Java's core code free and open-source, aside from a small portion of code to which Sun did not hold the copyright.[9] Primary goals There were five primary goals in the creation of the Java language: 1. It should be "simple, object oriented, and familiar". 2. It should be "robust and secure". 3. It should be "architecture neutral and portable". 4. It should execute with "high performance". 5. It should be "interpreted, threaded, and dynamic".

3

However.parts of the program. which means that computer programs written in the Java language must run similarly on any supported hardware/operating-system platform. In some JVM versions. Standardized libraries provide a generic way to access host specific features such as graphics. and can identify hot spots . This gap has been narrowed by a number of optimisation techniques introduced in the more recent JVM implementations. either before or during program execution. or in a Web browser. bytecode can be compiled to native code. in which the VM analyzes the behavior of the running program and selectively recompiles and optimizes parts of the program. Dynamic recompilation can achieve optimizations superior to static compilation because the dynamic compiler can base optimizations on knowledge about the runtime environment and the set of loaded classes. JIT compilation and dynamic recompilation allow Java programs to approach the speed of native code without losing portability. the overhead of interpretation means that interpreted programs almost always run more slowly than programs compiled to native executables would. This results in a program that starts and executes faster than pure interpreted code can. One such technique. that take up the most execution time. known as just-in-time compilation (JIT). then caches it. More sophisticated VMs also use dynamic recompilation. compile it once.Java Platform One characteristic of Java is portability. translates Java bytecode into native code the first time that code is executed. often inner loops. and Java suffered a reputation for poor performance. End-users commonly use a JRE installed on their own machine. 4 . resulting in faster execution. at the cost of introducing occasional compilation overhead during execution. threading and networking. This is achieved by compiling the Java language code. and run it anywhere. not to machine code but to Java bytecode – instructions analogous to machine code but intended to be interpreted by a virtual machine (VM) written specifically for the host hardware. A major benefit of using bytecode is Porting. One should be able to write a program once.

in runtime engine environments such as Java there exist tools that attach to the runtime engine and every time that an exception of interest occurs they record debugging information that existed in memory at the time the exception was thrown (stack and heap values). One of the unique advantages of the concept of a runtime engine is that errors (exceptions) should not 'crash' the system. and all the pointers are indirect with no way to micro manage garbage collection. at the expense of portability. These Automated Exception Handling tools provide 'root-cause' information for exceptions in Java programs that run in production. is to compile directly into native code like a more traditional compiler. only careful testing can reveal the true performance issues in any system. This resulted from a legal dispute with Microsoft after Sun claimed that the Microsoft implementation did not support RMI or JNI and had added platform-specific features of their own. the output of these compilers can only be run on a single architecture. and in 2001 won a settlement of $20 million as 5 . alternative Java environments are available for these and other platforms. and Solaris. Moreover. or ahead-of-time (AOT) compilation. Linux. This achieves good performance compared to interpretation.Another technique. The performance of the compilers does not necessarily indicate the performance of the compiled code. Static Java compilers translate the Java source or byte code to native object code. AOT could give Java something like performance. Implementations Sun Microsystems officially licenses the Java Standard Edition platform for Microsoft Windows. Java's performance has improved substantially since the early versions. and performance of JIT compilers relative to native compilers has in some tests been shown to be quite similar. Through a network of third-party vendors and licensees. commonly known as static compilation. yet it is still not portable since there are no compiler directives. testing or development environments. Sun's trademark license for usage of the Java brand insists that all implementations be "compatible". Sun sued in 1997.

Sun. such as Web services. a memory leak occurs. One of the ideas behind Java's automatic memory management model is that programmers be spared the burden of having to perform manual memory management. Sun is working to create a fully functional. using Embedded Java environments. and in recent versions of Windows. and others. Sun also distributes a superset of the JRE called the Java 2 SDK (more commonly known as the JDK). If the program does not deallocate an object. As a result. and Enterprise JavaBeans. Jar and debugger. Microsoft no longer ships Java with Windows. servlets. the result is undefined and the program may become 6 . typically when objects that are no longer needed are stored in containers that are still in use. The programmer determines when objects are created. In some languages memory for the creation of objects is implicitly allocated on the stack. Through the new GlassFish project. Platform-independent Java is essential to the Java Enterprise Edition strategy. Javadoc. Automatic memory management Java uses an automatic garbage collector to manage memory in the object lifecycle. and the Java runtime is responsible for recovering the memory once objects are no longer in use. which includes development tools such as the Java compiler. This environment enables portable server-side applications. as well as with embedded systems based on OSGi. unified open-source implementation of the Java EE technologies. Something similar to a memory leak may still occur if a programmer's code holds a reference to an object that is no longer needed. Internet Explorer cannot support Java applets without a third-party plugin. Once no references to an object remain.well as a court order enforcing the terms of the license from Sun. the unreachable object becomes eligible to be freed automatically by the garbage collector. Either way the responsibility of managing memory resides with the programmer. and an even more rigorous validation is required to certify an implementation. have made available free Java run-time systems for those and other versions of Windows. or explicitly allocated and deallocated from the heap. If the program attempts to access or deallocate memory that has already been deal located.

All code is written inside a class and everything is an object. with their object-oriented counterparts representing classes of their own. 7 . which are not classes for performance reasons. This is to allow the garbage collector to relocate referenced objects. Java suppresses several features (such as operator overloading and multiple inheritance) for classes in order to simplify the language and to prevent possible errors and antipattern design.0. where object addresses and integers (usually long integers) can be used interchangeably. It is guaranteed to occur if there is insufficient free memory on the heap to allocate a new object.unstable and/or may crash. Unlike C++. but it adds overhead and complexity. Because of this. which can cause a program to stall momentarily. However. autoboxing enables programmers to write as if primitive types are their wrapper classes. and freely interchange between them for improved flexibility. Java was built almost exclusively as an object oriented language. and characters). As in C++ and some other object-oriented languages. boolean values. explicit memory management and object pools are often used. Syntax The syntax of Java is largely derived from C++. Where performance or response time is important. Garbage collection is allowed to happen at any time. Ideally. and object-oriented programming. which combines the syntax for structured. This can be partially remedied by the use of smart pointers. Values of primitive types are either stored directly in fields (for objects) or on the stack (for methods) rather than on the heap. variables of Java's primitive types are not objects. Java was not considered to be a pure object-oriented programming language. with the exception of the intrinsic data types (ordinal and real numbers. Java does not support C/C++ style pointer arithmetic. generic. as is the common case for objects This was a conscious decision by Java's designers for performance reasons. it will occur when a program is idle. and to ensure type safety and security. as of Java 5.

Examples The canonical Hello world program can be written in Java as: // HelloWorld. appending the suffix . The class hierarchy is related to the name of the directory in which the. for example. or that a class may be used by classes outside the class hierarchy. Static methods cannot access any method variables that are not static.java public class HelloWorld { public static void main(String[] args) { System. The name of the class file is the name of the class. source files are named after the public class they contain. HelloWorld.java. a $.println("Hello. The compiler will generate a class file for each class defined in the source file. or 'launched'. anonymous classes are treated as if their name was the concatenation of the name of their enclosing class. } } By convention. The keyword static in front of a method indicates a static method. producing a file named HelloWorld.out. 8 . with . using a Java compiler. which is associated only with the class and not with any specific instance of that class. The java source file may only contain one public class but can contain multiple classes with less than public access.class. It must first be compiled into bytecode. For class file generation.class appended. and an integer. Only static methods can be invoked without a reference to an object.java file is. The keyword public denotes that a method can be called from code in other classes.java.java file. world!"). A class that is declared private may be stored in any . Only then can it be executed.

import java.swing. The Java launcher launches Java by loading a given class (specified on the command line or as an attribute in a JAR) and starting its public static void main(String[]) method. Applet Java applets are programs that are embedded in other applications. public class Hello extends JApplet { 9 . The String[] args parameter is an array of String objects containing any arguments passed to the class. typically in a Web page displayed in a Web browser.Graphics. The main method must accept an array of String objects.exit() The method name "main" is not a keyword in the Java language. The parameters to main are often passed by means of a command line.awt.. A java program may contain multiple classes that have main methods. but allows an alternate syntax for creating and passing the array. The effect of this alternate declaration is semantically identical (the args parameter is still an array of String objects).JApplet. allowing the main method to be invoked with an arbitrary number of String arguments. which means that the VM needs to be explicitly told which class to launch from.. // Hello. in the form of public static void main(String. Stand-alone programs must declare this method explicitly. the main method can also use variable arguments.java import javax. Java classes that run in managed environments such as applets and Enterprise Java Beans do not use or need a main() method. it is referenced as args although any other legal identifier name can be used. it must call System. By convention. If a Java program is to exit with an error code. It is simply the name of the method the Java launcher calls to pass control to the program. Since Java 5.The keyword void indicates that the main method does not return any value to the caller. args).

w3.Applet).org/TR/html4/strict.applet. The Applet class is an Abstract Windowing Toolkit (AWT) Component. the Applet class provides the framework for the host application to display and control the lifecycle of the applet. } } The import statements direct the Java compiler to include the java. 95) from the upper-left corner in the applet's display. The Hello class overrides the paint(Graphics) method inherited from the Container superclass to provide the code to display the applet. Applet) instead of the fully qualified class name (i. The Hello class extends (subclasses) the Applet class.dtd"> <!-.Graphics classes in the compilation. The import statement allows these classes to be referenced in the source code using the simple class name (i. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4. 65.e. which provides the applet with the capability to display a graphical user interface (GUI) and respond to user events.html --> <html> <head> <title>Hello World Applet</title> </head> <body> <applet code="Hello" width="200" height="200"> 10 .Applet and java. The paint() method calls the graphic context drawString(String.applet. world!". int) method to display the "Hello. java. int. The paint() method is passed a Graphics object that contains the graphic context used to display the applet.01//EN" "http://www.public void paintComponent(Graphics gc) { gc. 95).awt.e. world!" string at a pixel offset of (65.Hello.drawString("Hello.

GTK and Motif are supplied by Sun. The host application.BorderLayout.awt. Clones of Windows. Swing application Swing is a graphical user interface library for the Java SE platform. instantiates the Hello applet and creates an AppletContext for the applet.java (Java SE 5) import java. The applet tag has three attributes set: code="Hello" specifies the name of the Applet class and width="200" height="200" sets the pixel width and height of the applet.[16] However. import javax. The paint method is called by the AWT event dispatching thread whenever the display needs the applet to draw itself. Apple also provides an Aqua look and feel for Mac OS X. it is added to the AWT display hierarchy. world!" inside: // Hello.**. so the object tag is preferred where supported. Though prior implementations of these looks and feels have been considered lacking. This example Swing application creates a single window with "Hello. Swing in Java SE 6 addresses this problem by using more native widget drawing routines of the underlying platforms. although support for these elements by Web browsers is inconsistent.</applet> </body> </html> An applet is placed in an HTML document using the <applet> HTML element. typically a Web browser.swing. Applets may also be embedded in HTML using either the object or embed element[15]. public class Hello extends JFrame { public Hello() { 11 . Once the applet has initialized itself. It is possible to specify a different look and feel through the pluggable look and feel system of Swing. the applet tag is deprecated.

super("hello"). It then calls the setDefaultCloseOperation(int) method inherited from JFrame to set the default operation when the close control on the title bar is selected to WindowConstants. The Hello class extends the JFrame class.setVisible(true). Next. } } The first import statement directs the Java compiler to include the BorderLayout class from the java. setDefaultCloseOperation(WindowConstants. setLayout(new BorderLayout()). the JFrame class implements a window with a title bar and a close control. The Hello() constructor initializes the frame by first calling the superclass constructor. A JLabel is created for the string "Hello. the second import includes all of the public classes and interfaces from the javax. the layout of the frame is set to a BorderLayout.awt package in the compilation. which is used as the window's title.swing package. world!")). in the manner indicated by the Border Layout. The pack() method inherited from the Window superclass is called to size the window and lay out its contents. this tells Swing how to arrange the components that will be added to the frame.EXIT_ON_CLOSE — this causes the JFrame to be disposed of when the frame is closed (as opposed to merely hidden). which allows the JVM to exit and the program to terminate. 12 . add(new JLabel("Hello. passing the parameter "hello". world!" and the add(Component) method inherited from the Container superclass is called to add the label to the frame. } public static void main(String[] args) { new Hello(). pack().EXIT_ON_CLOSE).

Generics allow compile-time type checking without having to create a large number of container classes. Validating) libraries Security Internationalization and localization libraries    o The integration libraries. Transforming. dictionaries. Examples of these libraries are: o The core libraries. These libraries include:   The Java Database Connectivity (JDBC) API for database access Java Naming and Directory Interface (JNDI) for lookup and discovery 13 . or a different container class has to be created for each contained class. Either the container operates on all subtypes of a class or interface. this is a problem because there is no easy way to create a container that accepts only specific types of objects. Generics Prior to generics. each containing almost identical code. For container classes. Class libraries • Java libraries are the compiled byte codes of source code developed by the JRE implementer to support application development in Java. Note that once the frame is displayed. usually Object. trees and sets XML Processing (Parsing. which allow the application writer to communicate with external systems. exiting the main method does not cause the program to terminate because the AWT event dispatching thread remains active until all of the Swing top-level windows have been disposed. It instantiates a new Hello frame and causes it to be displayed by calling the set Visible(Boolean) method inherited from the Component superclass with the Boolean parameter true. for example.The main() method is called by the JVM when the program starts. which include:  Collection libraries that implement data structures such as lists. each variable declaration had to be of a specific type.

You declare packages when you define your Java program. which are built on AWT but provide (non-native) implementations of the AWT widgetry APIs for audio capture. must be the package declaration. processing. and you name the packages you want to use from other libraries in an import statement. 14 . which provides GUI components. • PACKAGES USED IN DOWNLOAD MANAGER Java classes can be grouped together in packages. or native) Abstract Windowing Toolkit (AWT). Package declaration The first statement. and playback User Interface libraries. A package name is the same as the directory (folder) name which contains the . which include:    • A platform dependent implementation of Java virtual machine (JVM) that is the means by which the byte codes of the Java libraries and third party applications are executed • • Plugins.java files. other than comments. in a Java source file. o RMI and CORBA for distributed application development The (heavyweight. which allows Java applications to be efficiently distributed to end users across the Internet Licensing and documentation. which enable applets to be run in Web browsers Java Web Start. the means for laying out those components and the means for handling events from those components The (lightweight) Swing libraries.

which is located in the javax package. This is the most common programming style. 3. which allow you to specify classes from other packages that can be referenced without qualifying them with their package. Comments can go anywhere.*. Class or interface definitions. 2. 1. Sun recommends that you do not use default packages. Package statment (optional)..java in the illustration directory. public class Drawing { .awt. The wildcard character (*) is used to specify that all classes with that package are available to your program. package illustration.Following the optional package declaration. Imports (optional). 15 . you can have import statements.. Package declaration syntax The statement order is as follows. in which case Java creates what it calls a default package. For small programs it's common to omit it. Altho all Java classes are in a directory. Default package. import java. } Imports: The JOptionPane class is in the swing package. it's possible to omit the package declaration. // This source file must be Drawing.

// Make all classes visible altho only one is used. class ImportTest { public static void main(String[] args) { JOptionPane. } } Alternately we can the fully qualified class name without an import. "Hi"). System. System.showMessageDialog(null. System. class ImportTest { public static void main(String[] args) { JOptionPane. "Hi"). "Hi").exit(0).JOptionPane. } 16 .swing.exit(0).swing. // Make a single class visible. class ImportTest { public static void main(String[] args) { javax.swing.JOptionPane. } } Classes can be specified explicitly on import instead of using the wildcard character.import javax.*. import javax.showMessageDialog(null.exit(0).showMessageDialog(null.

Common imports There are 166 packages containing 3279 classes and interfaces in Java 5. However, only a few packages are used in most programming. GUI programs typically use at least the first three imports. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import java.io.*; import java.text.*; Common GUI elements. The most common GUI event listeners. More common GUI elements. Note "javax". Data structures (Collections), time, Scanner, etc classes. Input-output classes. Some formatting classes.

17

MAIN MODULE AND USER INTERFACE

MAIN MODULE AND USER INTERFACE

18

1.

User Interface

The package must be user friendly and robust. It must prompt the user with proper message`` boxes to help them perform various actions and how to precede further the system must respond normally under any in out conditions and display proper message instead of turning up faults and errors.

2.

Hardware Specification
SPECIFICATION

HARDWARE

CPU

Intel Pentium IV

OPERATING SYSTEM

XP –Service Pack 2

RAM

256 MB

HARD DISK

80GB

KEYBOARD

105 keys

3. Software Specifications

19

documents.Software is a set of program. Software is an essential complement to hardware. routines associated with computer system. It is the computer programs which when executed operate the hardware. and procedure. JAVA (as front end) 20 . The “Download Manager” has been developed using the following tools: 1.

FEASIBILITY STUDY FEASIBILITY STUDY 21 .

Thus there was no reason for the project to be socially infeasible. outputs benefit analysis in terms of increase on Social Feasibility: Although generally there is always resistance to any change in the system. Moreover.Through all this it was concluded that the system was indeed economically feasible. performance. The cost productivity and better utilization of man-hours was done. Operational Feasibility: 22 . information. The system is going to help the end user perform the maintenance of records and report generation with the least possible errors. The analysis clearly pointed to the fact that a good amount of economic benefit in terms of better utilization of man-hours can be obtained if the proposed system was indeed implemented. from the system were studied. the system is aimed at relieving the work-load of the end users and provide convenience to the students.Economic Feasibility: While considering the economic feasibility . as the hardware and software resources required were already available in the organization. Moreover precious time of students during the examination period can be saved. no overheads would be incurred.

All the forms and pages used in the software are of the same design etc. as used earlier in paperwork and moreover the users also had familiarity with computers in general. Proposed system had sufficient support from management and from users . 23 .Proposed projects are feasible only if they meet the organization’s operating requirements. So there was no resistance in this regard also. On the whole the project was found to be fit for development in almost every criterion and hence was given a ‘ go ahead’ by everyone concerned.

INTRODUCTION TO OPERATING SYSTEM INTRODUCTION TO OPERATING SYSTEM 24 .

desktop computers. Operating systems offer a number of services to application programs and users. Some of the oldest models may however use an embedded operating system. By invoking these interfaces. Mac OS. supercomputers. Linux and Solaris. Microsoft Windows has a significant majority of market share in the desktop and notebook computer markets. This relieves application programs from having to manage these details and makes it easier to write applications. The operating system acts as a host for applications that are run on the machine. the user interface is generally considered part of the operating system. Applications access these services through application programming interfaces (APIs) or system calls.) Common contemporary operating systems include Microsoft Windows. On large multiuser systems like Unix and Unix-like systems. commonly pronounced “gooey”). As a host. the application can request a service from the operating system. (Whether the user interface should be included as part of the operating system is a point of contention. that may be contained on a compact disk or other data storage device. including handheld computers. the user interface is generally implemented as an application program that runs outside the operating system.An operating system (commonly abbreviated OS and O/S) is the infrastructure software component of a computer system. Users may also interact with the operating system with some kind a software user interface (UI) like typing commands by using command line interface (CLI) or using a graphical user interface (GUI. one of the purposes of an operating system is to handle the details of the operation of the hardware. it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer. 25 . For hand-held and desktop computers. pass parameters. Embedded device markets are split amongst several operating systems. and receive the results of the operation. Almost all computers. use an operating system of some type. while servers generally run on Linux or other Unix-like systems. and even video game consoles.

The kernel creates a process by setting aside or allocating some memory. certain protected mode registers specify to the CPU what memory address it should allow a running program to access. including memory segmentation and paging. With cooperative memory management it takes only one misbehaved program to crash the system. used by many early operating systems assumes that all programs make voluntary use of the kernel's memory manager. Memory management Among other things. each program must have independent access to memory. This system of memory management is almost never seen anymore. If a program fails it may cause memory used by one or more other programs to be affected or overwritten. All methods require some level of hardware support (such as the 80286 MMU) which doesn't exist in all computers. loading program code from a disk or another part of memory into the newly allocated space. a multiprogramming operating system kernel must be responsible for managing all system memory which is currently in use by programs. This ensures that a program does not interfere with memory already used by another program. Cooperative memory management. Various methods of memory protection exist. In both segmentation and paging. or viruses may purposefully alter another program's memory or may affect the operation of the operating system itself. Malicious programs.Program execution Executing a program involves the creation of a process by the operating system. Since programs time share. and do not exceed their allocated memory. Attempts to access other addresses will trigger an interrupt which will cause the CPU to re-enter supervisor 26 . and executing the initial program. since programs often contain bugs which can cause them to exceed their allocated memory. Memory protection enables the kernel to limit a process' access to the computer's memory.

This is called a segmentation violation or Seg-V for short. or even whether or not it has actually been allocated yet. In LINUX systems. This gives the kernel discretionary power over where a particular application's memory is stored. the kernel will generally resort to terminating the offending program. but nonetheless has been allocated to it. and will report the error. application memory which is accessed less frequently can be temporarily stored on disk or other media to make that space available for use by other 27 . Under Windows 9x all MS-DOS applications ran in supervisor mode.) Under UNIX this kind of interrupt is referred to as a page fault. A general protection fault would be produced indicating a segmentation violation had occurred. Virtual memory The use of virtual memory addressing (such as paging or segmentation) means that the kernel can choose which memory each program may use at any given time. allowing the operating system to use the same memory locations for multiple tasks. and because it is usually a sign of a misbehaving program. granting it access to the memory requested. and since it is both difficult to assign a meaningful result to such an operation. the kernel will be interrupted in the same way as it would if the program were to exceed its allocated memory. giving them almost unlimited control over the computer. (See section on memory management. When the kernel detects a page fault it will generally adjust the virtual memory range of the program which triggered it.1-Me had some level of memory protection. but programs could easily circumvent the need to use it. however the system would often crash anyway. This part is known as swap space.mode. Windows 3. In modern operating systems. part of the hard disk is reserved for virtual memory when the Operating system is being installed on the system. If a program tries to access memory that isn't in its current range of accessible memory. placing the kernel in charge.

In this model. This implies that all programs must be limited in how much time they are allowed to spend on the CPU without being interrupted. and in which order execution control should be passed to programs. as an area of memory can be used by multiple programs. Multitasking Multitasking refers to the running of multiple independent computer programs on the same computer. A protected mode timer is set by the kernel which triggers a return to supervisor mode after the specified time has elapsed. To accomplish this. An early model which governed the allocation of time to programs was called cooperative multitasking. At a later time control is returned to the kernel through some mechanism. This is called swapping. when control is passed to a program by the kernel. giving the appearance that it is performing the tasks at the same time. and what that memory area contains can be swapped or exchanged on demand. which means that each program uses a share of the computer's time to execute. Control is passed to a process by the kernel. this is generally done via time sharing. but it can hang the entire system if it enters an infinite loop.) 28 . The philosophy governing preemptive multitasking is that of ensuring that all programs are given regular time on the CPU. This so-called passing of control between the kernel and applications is called a context switch. it may execute for as long as it wants before explicitly returning control to the kernel. (See above sections on Interrupts and Dual Mode Operation. Since most computers can do at most one or two things at one time.programs. modern operating system kernels make use of a timed interrupt. which allows the program access to the CPU and memory. An operating system kernel contains a piece of software called a scheduler which determines how much time each program will spend executing. so that another program may be allowed to use the CPU. This means that a malicious or malfunctioning program may not only prevent any other programs from using the CPU.

The specific way in which files are stored on a disk is called a file system. Windows NT was the first version of Microsoft Windows which enforced preemptive multitasking. Computers store data on disks using files. A modern operating system like UNIX supports a wide array of storage devices. The device driver understands the specific language of the drive and is able to translate that 29 . and to make better use out of the drive's available space. and in the kinds of file names and directory structures they could use.On many single user operating systems cooperative multitasking is perfectly adequate. A connected storage device such as a hard drive is accessed through a device driver. higher reliability. speed. It also allows them to be stored in a hierarchy of directories or folders arranged in a directory tree. making it very difficult for an operating system to support more than one file system. While many simpler operating systems support a limited range of options for accessing storage systems.) Disk access and file systems Access to files stored on disks is a central feature of all operating systems. This makes it unnecessary for programs to have any knowledge about the device they are accessing. but it didn't reach the home user market until Windows XP. (since Windows NT was targeted at professionals. These limitations often reflected limitations in the operating systems they were designed for. regardless of their design or file systems to be accessed through a common application programming interface (API). Early file systems were limited in their capacity. more modern operating systems like UNIX and Linux support a technology known as a virtual file system or VFS. and enables files to have names and attributes. as home computers generally run a small number of well tested programs. which are structured in specific ways in order to allow for faster access. A VFS allows the operating system to provide programs with access to an unlimited number of devices with an infinite variety of file systems installed on them through the use of specific device drivers and file system drivers. Early operating systems generally supported a single type of disk drive and only one kind of file system.

free space. including access permissions. NTFS is available in Linux through NTFS-3g. NTFS in Windows and extn and ReiserFS in Linux. it can then access the contents of the disk drive in raw format. Typically this constitutes an interface for communicating with the device. through the specific computer bus or communications subsystem that the hardware is connected to. for example. open. providing commands to and/or receiving data from the device. and close files. and creation and modification dates. Programs can then deal with these file systems on the basis of filenames. A file system driver is used to translate the commands used to access each specific file system into a standard set of commands that the operating system can use to talk to all file systems. case sensitivity. third party drives are usually available to give support for the most widely used filesystems in most general-purpose operating systems (for example. in practice. Device drivers A device driver is a specific type of computer software developed to allow interaction with hardware devices. Operating systems tend to recommend the use of (and so support natively) file systems specifically designed for them. size. contained within a hierarchical structure. However. which may contain one or more file systems. Various differences between file systems make supporting all file systems difficult.language into a standard language used by the operating system to access all disk drives. They can create. It is a specialized hardware-dependent computer program which is also 30 . Allowed characters in file names. delete. When the kernel has an appropriate device driver in place. and on the other end. and ext2/3 and ReiserFS are available in Windows through FS-driver and rfstool). as well as gather various information about them. On UNIX this is the language of block devices. and directories/folders. and the presence of various kinds of file attributes makes the implementation of a single interface for every file system a daunting task. the requisite interfaces to the operating system and software applications.

should function correctly if a suitable driver is available. typically an operating system or applications software package or computer program running under the operating system kernel. The key design goal of device drivers is abstraction.operating system specific that enables another program. This new driver will ensure that the device appears to operate as usual from the operating systems' point of view for any person. Newer models also are released by manufacturers that provide more reliable or better performance and these newer models are often controlled differently. In theory a new device. and usually provides the requisite interrupt handling necessary for any necessary asynchronous time-dependent hardware interfacing needs. The function of the device driver is then to translate these OS mandated function calls into device specific calls. 31 . both now and in the future. OSes essentially dictate how every type of device should be controlled. To solve this problem. which is controlled in a new manner. to interact transparently with a hardware device. Computers and their operating systems cannot be expected to know how to control every device. Every model of hardware (even within the same class of device) is different.

FLOW-CHART DIAGRAM D O W N LO AD M ANAG ER AD D D O W N LO AD PAUSE R ESUM E C AN CEL C LE AR 32 .

PROJECT INTRODUCTION PROJECT INTRODUCTION 33 .

The interface a crisp. use of Swings gives the Illustration of the download manager 34 .An overview of the Download Manager The download manager uses simple yet effective GUI interface built with java’s swing libraries the Download manager window is shown. modern look and feel.

The download manager is broken into few classes for natural separation of natural component these are : 1. Download Manager class Download Table Model class Progress Renderer class Download class : The download class is the workhouse of download manager its primary purpose is to download a file and save that a file to the hard disk each time a new download is added to the download manager a new download is instantiated to handle the download The download manager has the ability to multiple files at once .http download comes in two Forms 1. Resume able (HTTP 1.Download manager developed in this will only support http downloads. Download class 2..1) 2.0 a client can only request the server send it a file whereas the http 1.To achieve this its necessary for each of simultaneous download s to run independently . 4. Adding support for FTP is an excellent exercise for extending the code .0) The difference between these two forms lies in the way that the file can be requested from the server with the antiquated http1. Non Resume able(HTTP 1. 3.it also necessary for each download to manage its own state so that it can be reflected in GUI. Progress Renderer class : 35 .1 the client can request the server send it a complete file or only a specific portion of the file this is the feature the download manager is built on.

Download Table Model class : The download table model class houses the download managers list of download and is backing data source for the GUI’s downloads JTable instace it extends abstract table model and implement the observer interface . The progress Renderer class takes advantage of the fact that swings jtable class has a rendering system that can accept plugins for rendering table cell.The main method instantiate a new download manager class instance and then call its show () method . It extends jprogressbar and implement table cell and renderer. It extends JFrames and implements observer Objectives of download manager :- 36 .Normally a JTable instance renders each cells data as a text.The progress renderer class is small utility class that is use to render the current progress of download listed in the GUI’s downloads JTable instance . The Download Table model class essentially is a utility class utilized by the download s Jtable instance for managing data in a table Download Manager class : The download manager class is responsible for creating and running the download managers GUI the class has a main method declared so on execution it will be invoked first . which causes to be displayed.

how much the file is Downloaded.The download manager uses a simple GUI (Graphical user Interface ) built with java swings libraries which has following advantages: 1. 2. The use of swing give the interface a good look and feel. The additional features of download manager are listed below: 1. 3. The GUI maintains a list of downloads that are currently being managed. The GUI provides the facilities of adding . 5. 4. progress as a percentage toward completion and the current status of the download .so that if any type of exception come then it can be thrown . Each download defines the size of file in bytes. 4. The GUI also has control for adding download to a list and for changing the state of each download in the list.e.pause the status of download or canceling of downloading. It has the exception handling mechanism . stopping and pausing the current status of downloading. The download manager has the ability to download multiple files. 2. The GUI table provides the overview of the Downloading file i. FEATURES OF DOWNLOAD MANAGER: The primary purpose of the download manager is to download a file and save that file into the disk.The status of every running download can be change by using the specific control buttons like the stopping of a running downloading file . 3. 37 .

There are three downloading’s shown as one of the one shows the complete downloading and second one shows the downloading status and the third one is paused and that’s the way how it works. 38 .5.The download manager has the maximum buffer size so that big files can be easily downloaded and easily saved to disk space. The output of the Download Manger is given below as:- The above Diagram shows simultaneous downloading’s with different status as described.

SOURCE CODE FOR DOWNLOAD MANAGER 39 .

getRowCount() . class DownloadsTableModel extends AbstractTableModel implements Observer { private static final String[] columnNames = {"URL". JProgressBar. private static final Class[] columnClasses = {String.*. import javax. "Size".util.add(download).class}.class.swing. public void addDownload(Download download) { download.SOURCE CODE FOR DOWNLOAD MANAGER Download table model:import java. 40 .*.swing.1. "Progress". String. "Status"}. import javax. private ArrayList<Download> downloadList = new ArrayList<Download>().*. fireTableRowsInserted(getRowCount() .class.table.addObserver(this).1). String.class. downloadList.

} public void clearDownload(int row) { downloadList.length.} public Download getDownload(int row) { return (Download) downloadList. } public int getColumnCount() { return columnNames.remove(row).get(row). } public Class getColumnClass(int col) { return columnClasses[col]. 41 . row). fireTableRowsDeleted(row. } public int getRowCount() { return downloadList. } public String getColumnName(int col) { return columnNames[col].size().

toString(size). fireTableRowsUpdated(index. } return "". 42 . } } Progress Renderer class:import java. Object arg) { int index = downloadList.STATUSES[download.awt.getUrl(). return (size == -1) ? "" : Integer. case 1 int size = download.getSize(). case 2: return new Float(download.getStatus()]. index).get(row).} public Object getValueAt(int row. } public void update(Observable o. switch (col) { case 0: return download. case 3 return Download.getProgress()).indexOf(o). int col) { Download download = downloadList.*.

int column) { setValue((int) ((Float) value). int row.*. int max) { super(min. } } Download Manager:import java. max).swing. return this. boolean isSelected.table. import javax.floatValue()). } public Component getTableCellRendererComponent( JTable table. Object value. 43 .awt.import javax. class ProgressRenderer extends JProgressBar implements TableCellRenderer { public ProgressRenderer(int min.*.swing. boolean hasFocus.*.

. private JButton cancelButton.import java.net. resumeButton.swing.event.*. public class DownloadManager extends JFrame implements Observer { private JTextField addTextField. .*.event. import javax.swing. import java. .util.*. import java.*.*.awt. import javax. private Download selectedDownload. private boolean clearing. private JTable table. private DownloadsTableModel tableModel. clearButton. private JButton pauseButton. 44 .

} }). 480). JMenuBar menuBar = new JMenuBar(). fileExitMenuItem. 45 . KeyEvent. JMenuItem fileExitMenuItem = new JMenuItem("Exit".addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionExit().public DownloadManager() { setTitle("Download Manager"). addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { actionExit(). JMenu fileMenu = new JMenu("File").VK_X). setSize(640.setMnemonic(KeyEvent. fileMenu.VK_F).

addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionAdd(). menuBar. JButton addButton = new JButton("Add Download"). tableModel = new DownloadsTableModel(). 46 .add(fileExitMenuItem). addTextField = new JTextField(30). fileMenu.add(fileMenu). } }).add(addButton). setJMenuBar(menuBar). addPanel. addButton. JPanel addPanel = new JPanel().add(addTextField).} }). addPanel.

} } ).setRowHeight( (int) renderer.setStringPainted(true).setSelectionMode(ListSelectionModel. 100). renderer). 47 . JPanel downloadsPanel = new JPanel(). renderer. table.getPreferredSize(). // show progress text table. ProgressRenderer renderer = new ProgressRenderer(0.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { tableSelectionChanged(). .getSelectionModel().table = new JTable(tableModel). .class. table.SINGLE_SELECTION). table. .getHeight()).setDefaultRenderer(JProgressBar.

add(pauseButton).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionPause(). downloadsPanel. BorderLayout.CENTER). pauseButton.setEnabled(false). } } ). resumeButton. pauseButton = new JButton("Pause").add(new JScrollPane(table). pauseButton.setLayout(new BorderLayout()). buttonsPanel. JPanel buttonsPanel = new JPanel().downloadsPanel. downloadsPanel. resumeButton = new JButton("Resume").setBorder( BorderFactory.createTitledBorder("Downloads")).addActionListener(new ActionListener() { 48 .

clearButton = new JButton("Clear").setEnabled(false). clearButton. } }). } 49 . cancelButton. cancelButton = new JButton("Cancel"). } }). buttonsPanel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionCancel().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionClear(). resumeButton. buttonsPanel.public void actionPerformed(ActionEvent e) { actionResume(). cancelButton.setEnabled(false).add(cancelButton).add(resumeButton).

addDownload(new Download(verifiedUrl)).exit(0). addTextField. BorderLayout.add(buttonsPanel. buttonsPanel.SOUTH). // reset add text field } 50 . getContentPane().add(addPanel. clearButton. } private void actionExit() { System. } private void actionAdd() { URL verifiedUrl = verifyUrl(addTextField.NORTH). getContentPane().setText(""). getContentPane(). if (verifiedUrl != null) { tableModel.CENTER). BorderLayout. BorderLayout.add(clearButton).setEnabled(false).setLayout(new BorderLayout()).add(downloadsPanel. getContentPane().} ).getText()).

ERROR_MESSAGE). "Invalid Download URL".else { JOptionPane.showMessageDialog(this. try { verifiedUrl = new URL(url). 51 . "Error". JOptionPane. } } private URL verifyUrl(String url) { . } catch (Exception e) { return null. if (!url. } . URL verifiedUrl = null.startsWith("http://")) return null.toLowerCase().

if (!clearing && table. selectedDownload. private void tableSelectionChanged() { if (selectedDownload != null) selectedDownload.this).addObserver(DownloadManager. } } private void actionPause() { 52 .getFile().length() < 2) return null.deleteObserver(DownloadManager.getSelectedRow() > -1) { selectedDownload = tableModel. } . updateButtons().if (verifiedUrl.getSelectedRow()). return verifiedUrl.getDownload(table.this).

pause(). } private void actionClear() { clearing = true. } private void actionResume() { selectedDownload. updateButtons(). updateButtons().resume(). } private void actionCancel() { selectedDownload. updateButtons().getSelectedRow()).cancel().clearDownload(table. tableModel. 53 . clearing = false. selectedDownload = null.selectedDownload.

cancelButton. } private void updateButtons() { if (selectedDownload != null) { int status = selectedDownload.setEnabled(true).updateButtons().setEnabled(false). 54 . case Download.setEnabled(false).DOWNLOADING: pauseButton. clearButton.setEnabled(true).setEnabled(true). break.getStatus(). cancelButton.setEnabled(true). resumeButton. switch (status) { case Download. resumeButton.setEnabled(false).PAUSED: pauseButton.

break. cancelButton.setEnabled(false). clearButton. 55 .setEnabled(false). case Download.setEnabled(true).setEnabled(false).setEnabled(false).clearButton. resumeButton.setEnabled(true). default: pauseButton.setEnabled(false).setEnabled(false). break. } } else { pauseButton.setEnabled(true). resumeButton.ERROR: pauseButton. clearButton. cancelButton.setEnabled(false).

} } public void update(Observable o.setVisible(true). manager. } public static void main(String[] args) { DownloadManager manager = new DownloadManager(). Object arg) { if (selectedDownload != null && selectedDownload.setEnabled(false).setEnabled(false). cancelButton. clearButton. } } 56 .equals(o)) updateButtons().setEnabled(false).resumeButton.

LIMITATIONS 57 .

process and the data has to be 58 .Limitations 1.0) and if there is any error or let if the power fails. If we are working with the Non Resume able (HTTP 1. 2. if the URL does not allow the Resume option and we cannot pause our downloading downloaded contiguously. The resume option is functional in the download manager only if the URL from which we are downloading the data allows us that option. then we cannot resume the downloading process from the point of failure we again have to start afresh and start downloading from the initial state.

REFERENCES 59 .

W. Peterson. ii. iv. (1971. Silberschatz. Techmedia DOWNLOAD MANAGER REFRENCES i. Operating Systems Concepts. et al.REFERENCES JAVA REFERENCES i. (1988). ii. E.Comdex Computer Publishing Mircosoft Exchange Server Unleashed By Greg Todd.Techmedia World Wide Web Secrets By Paul J. Abraham. June). Acta Informatica 1(2): 115-138. iii. Perry .Harbert Schildt TATA McGrawHill JAVA 2 Unleashed By Jamie Jawroski . The Complete Reference JAVA 2 By Patrick Naughton. 60 . Hierarchical ordering of sequential processes. Dijkstra. Addison-Wesley. James L.