




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































2. LAB REQUIREMENTS
For Java Programming
J2SDK 1. Java Compatible Web Browser
This Compiler has no special hardware requirements as such. Any System with a minimum 256 MB RAM and any normal processor can use for this lab.
JAVA PROGRAMMING LAB Paper Code: ETCS- Paper: Java Programming Lab
List of Experiments: (As prescribed by G.G.S.I.P.U)
NOTE:- At least 8 Experiments out of the list must be done in the semester.
Week 5
5. PROJECTS TO BE ALLOTED (Beyond the syllabus prescribed by G.G.S.I.P.U)
Students will be divided into a group of four/five and projects are allotted to those groups. This project is to be submitted at the end of the semester along with a project report by the individual student.
List of projects given to the students is summarized as below:
Dx Ball Game Moving ball with Java Script Checker Board game with Java Script Digital Image Processing Library Management System Global Defender Game Brick Game Rapid Roll Game Tic Tack Toe
Students can select project work of their own choice subject to the permission of concern faculty.
NOTE : The project is to be made in Java Language preferably.
6. FORMAT OF THE LAB RECORD TO BE PREPARED BY THE STUDENTS 1. The front page of the lab record prepared by the students should have a cover page as displayed below.
NAME OF THE LAB Font should be (Size 20‖, italics bold, Times New Roman)
Faculty name Student name Font should be (12‖, Times Roman) Roll No.: Semester: Group: Font should be (12‖, Times Roman)
Maharaja Agrasen Institute of Technology, PSP Area, Sector – 22, Rohini, New Delhi – 110085 Font should be (18‖, Times Roman)
a) YES b) NO
( ) ( )
7. MARKING SCHEME FOR THE PRACTICAL EXAMS
There will be two practical exams in each semester.
Internal Practical Exam External Practical Exam
INTERNAL PRACTICAL EXAM
It is taken by the concerned lecturer of the batch.
MARKING SCHEME FOR THIS EXAM IS :
Total Marks: 40
Division of 40 marks is as follows
NOTE: For the regularity, marks are awarded to the student out of 10 for each experiment performed in the lab and at the end the average marks are giving out of 25.
8. DETAILS OF THE EACH SECTION ALONG WITH EXAMPLES, EXERCISES & EXPECTED VIVA QUESTIONS
Java Programming
Anyone who is learning to program has to choose a programming environment that makes it possible to create and to run programs. Programming environments can be divided into two very different types: integrated development environments and command-line environments. All programming environments for Java require some text editing capability, a Java compiler, and a way to run applets and stand-alone applications. An integrated development environment, or IDE, is a graphical user interface program that integrates all these aspects of programming and probably others (such as a debugger, a visual interface builder, and project management). A command-line environment is just a collection of commands that can be typed in to edit files, compile source code, and run programs.
Command line environment is preferable for beginning programmers. IDEs can simplify the management of large numbers of files in a complex project, but they are themselves complex programs that add another level of complications to the already difficult task of learning the fundamentals of programming.
Java was developed at Sun Microsystems, Inc., and the primary source for information about Java is Sun's Java Web site, http://java.sun.com/. At this site, one can read documentation on-line and you can download documentation and software. The documentation includes the Java API reference and the Java tutorial.
The current version of Java on the Sun site is version 1.4. It is available for the Windows, Linux, and Solaris operating systems. One can download the "J2SE 1.4 SDK." This is the "Java 2 Platform Standard Edition Version 1.4 Software Development Kit." This package includes a Java compiler, a Java virtual machine that can be used to run Java programs, and all the standard Java packages. The JRE is the "Java Runtime Environment." It only includes the parts of the system that are needed to run Java programs. It does not have a compiler.
Text Editors
To use a command-line environment for programming good text editor is needed. A programmer's text editor is a very different thing from a word processor. Most important, it saves work in plain text files and it doesn't insert extra carriage returns beyond the ones you actually type. A good programmer's text editor will do a lot more than this. Here are some features to look for:
Syntax coloring. Shows comments, strings, keywords, etc., in different colors to make the program easier to read and to help you find certain kinds of errors. Function menu. A pop-up menu that lists the functions in your source code. Selecting a function from this will take you directly to that function in the code. Auto-indentation. When you indent one line, the editor will indent following lines to match, since that's what you want more often than not when you are typing a program. Parenthesis matching. After typing a closing parenthesis the cursor jumps back to the matching parenthesis momentarily so one can see where it is. Alternatively, there might be a command that will highlight all the text between matching parentheses. The same thing works for brackets and braces. Indent Block and Unindent Block commands. These commands apply to a highlighted block of text. They will insert or remove spaces at the beginning of each line to increase or decrease the indentation level of that block of text. When you make changes in your program, these commands can help you keep the indentation in line with the structure of the program. Control of tabs. Don‘t use tab characters for indentation. A good editor can be configured to insert multiple space characters when tab key is pressed.
There are many free text editors that have some or all of these features. Jedit ,a programmer's text editor written entirely in Java. It requires Java 1.3 or better. It has many features listed above, and there are plug-ins available to add additional features. Since it is written in pure Java, it can be used on any operating system that supports Java 1.3. In addition to being a nice text editor, it shows what can be done with the Swing GUI. Jedit is free and can be downloaded from http://www.jedit.org.
On Linux, use nedit. It has all the above features, except a function menu. Under Linux, it is likely that nedit is included in distribution, although it may not have been installed by default. It can be downloaded from http://www.nedit.org/ and is available for many UNIX platforms in addition to Linux. Features such as syntax coloring and auto-indentation are not turned on by default. One can configure them in the Options menu. Use the "Save Options" command to make the configuration permanent. Of course, as alternatives to nedit, the Gnome and KDE desktops for Linux have their own text editors.
Using the Java SDK
After installing Sun's Software Development Kit for Java, one can use the commands "javac", "java", and "appletviewer" for compiling and running Java programs and applets. These commands must be on the "path" where the operating system searches for commands.
Make a directory to hold Java programs. Create program with a text editor, or copy the program to be compiled into program directory
If program contains more than a few errors, most of them will scroll out of the window. In Linux and UNIX, a command window usually has a scroll bar that can be used to review the errors. In Windows 2000 to 2010/NT/XP (but not Windows 95/98), one can save the errors in a file which can be viewed later in a text editor.
The command in Windows is
javac SourceFile.java >& errors.txt
The ">& errors.txt" redirects the output from the compiler to the file, instead of to the DOS window. It is possible to compile all the Java files in a directory at one time. Use the command "javac *.java".
After compiled class files are made, run application or applet. For running a stand-alone application -- one that has a main () routine -- use the "java" command from the SDK to run the application. If the class file that contains the main () routine is named Main. class, then run the program with the command: