Java Training Report
Java Training Report
ON
Branch-CSE
Acknowledgement
It gives me an immense pleasure to acknowledge my indebtedness and
a deep sense of
gratitude to Mr. Vikas Pathak, Training Experts, Technology Uncorked
for his valuable
guidance and encouraging attitude throughout the work, without which
it would not have
possible to present this work in its present shape.
XYZ
Certificate
I hereby declare that the work which is being presented in this
training report entitled
JAVA AND towards
PHP, the partial fulfillment for the award of Bachelor of
Technology in Computer Engineering, submitted in the Department
of Computer
Engineering at Maharishi Markandeshwar Univesity, Mullana, is
record of my work
carried out from under the Guidance of NIIT Campus Connect.
ORGANIZATION INTRODUCTION
Preface
Contents
1. Introduction
2. Characteristics of java
3. Java and C
4. Java and C++
5. Object Oriented Principles
6. Classes and Objects
7. Declaring class members
8. Java Architecture
9. Garbage Collection in JVM
10. Java Bytecode
11. JVM
12. Packages
12.1 API
12.2 User-Defined Packages
13. J2ME or JAVA ME
14. J2EE or JAVA EE
15. PHP
Introduction
Java is a high-level,
generation
3 rd computer programming language that is
concurrent, object-oriented, class based and portable across platforms. It
is developed by
Sun Microsystems. It is intended to let application developers "write
once, run anywhere"
(WORA), meaning that code that runs on one platform does not need to
be recompiled to
run on another. The creator of Java is James Gosling, chief
programmer of Sun
Microsystems. Java is most similar to C. The most special thing about
Java in relation to
other programming languages is that it lets you write special programs
called applets that
can be downloaded from the Internet and played safely within a web
browser.
Java is used to write computer applications that play games, store data
or do any
of the thousands of other things computer software can do. It is also
used to implement
the web sites and web pages. Java is used to develop stand-alone
and Internet based
applications. The main region to use java is that it is more secure. Java
software works
everywhere, from the smallest devices, such as microwave ovens and
remote controls to
supercomputers.
Characteristics of Java:
1) Platform Independent
Java is a platform for application development. A platform is a loosely
def ined computer
industry buzzword that typically means some combination of
hardware and system
software that will mostly run all the same software.
machine
Java
compiled
The
interpreter
byteon
into
code
the
byte
reads
isfly.code
exactly
the
Since
still
byte
the
the
need
code
same
byte
an
and
interpreter
on
code
translates
every
is completely
to
platform..
itexecute
into thethem
platform
Java
nativeon any
programs
given
language
independent,
platform.
ofthat
the
only
have
hostthebeen
Java byte codes can be compiled on the fly to code that rivals C++ in
speed using a "justin-time compiler." Several companies are also working on nativemachine-architecture
compilers for Java. These will produce executable code that does not
require a separate
interpreter, and that is indistinguishable in speed from C++.
6) Dynamic
Java programs carr y with them substantial amounts of run-time type
information that is
used to verify and resolve accesses to objects at run-time. This
makes it possible to
dynamically link code in a safe and expedite manner. The java
programming language is
unusual than other programming languages it first compiles and
then interprets the
program. Compile first translate the program into intermediate
language called
intermediate language called java byte code. Java byte code is
platform independent
code, which is further interpreted by the interpreter on the java
platform. Interpreter
parses and run each java byte code instruction on the computer.
Compilation occurs only
once, interpretation occurs each time when the program is executed.
Fig 1.1
Java byte code helps in making the program write once, run
can
compiled
be compiled
java
byteprogram
into
codebyte
program
code isbyready
any to
platform
run on any
thatmachine
is having
having
the
anywhere.
The
javajava
the
machine
Need
compiler;
of virtual
Java
(JVM).theJVM is an interpreter for byte code.
The main motive for developing java was to meet the need of
portable and platform
independent language that could be used to produce code that would run
on a variety of
systems.
Java and C
Java does not include keywords like goto , sizeof and typedef.
Java does not contain data types like struct, union and enum.
Java does not define the type modifiers keywords like auto, register,
signed.
Java does not support an explicit pointer type.
Java does not have preprocessor.
Java does not support variables arguments to functions.
Java adds many features required for Object-Oriented Progr amming.
7 to27 -1
(signed)
Short Two byte -2
15 to215
31 to231 -1
63 to
-1 0
0
263 -1 0
e-0.38
to
0.0
to
0.0
3.4e+0.38
e-308
1.7e+308
Boolean Boolean One bit True or false False
Character Char Two byte A single
Null
character
Objects
Arrays
Enums
Integer literals
oo Architecture
Floating
point
literals
Java
Character
String
Boolean
literals
literal
literals
JVM
Class Loader
Execution engine
Computer
Java
Java
Operating
Virtual
interpreter
JavaMachine
Compiler
System
JavaObj
Code
ect
Java Bytecode
Java bytecode is the form of instructions that the Java virtual
machine executes.
Each bytecode is one byte in length, although some require parameters,
resulting in some
multi-byte instructions. A Java programmer does not need to be aware
of or understand
Java bytecode. Understanding bytecode and what bytecode is likely to
be generated by a
Java compiler helps the Java programmer in the same way that
knowledge
of assembly helps the C or C++ programmer.
The JVM runtime executes .class or .jar files, emulating the JVM
instruction
set by interpreting it or using a just-in-time compiler (JIT) such as
Oracle's Hot Spot. JIT
compiling, not interpreting, is used in most JVMs today to achieve
greater speed. There
are also ahead-of-time compilers that enable developers to precompile class files into
native code for particular platforms.
Like most virtual machines, the Java virtual machine has a stack-based
architecture akin
to a microcontroller/microprocessor. However, the JVM also has
low-level support for
Java-like classes and methods, which amounts to a highly
idiosyncratic memory
model and capability-based architecture.
Packages
o Java User defined Packages: The packages that a user creates are
called userdefined packages. The user-defined packages can be imported in
any Java
program.
Java API
The java API contains classes that are grouped in different
packages in
accordance to their functions.
The file containing the package is saved as .java file. After compiling
the source code, the
.class file is created that is stored in the directory having the same name
as the package
name.
Importing a User-Defined Package
A user defined package can be include using the import keyword.
In this we incuded user-defined package empDetails from app directory
import
Code:
in
a program.
app.empDetails.Employee J2ME or JAVA ME
INTRODUCTION:
You are leaving for work in the morning and someone rings the
doorbell.
That
is
an
In
them
the
to
the
life,
application.
immediately.
programs
youevent!
encounter
Java
using
InsJava,
Abstract
events
events.
events
that
Windowing
When
represent
forcetheyou
Toolkit
all
user
to
activity
interacts
suspend
(AWT)
that with
other
goes on
a
activitiesthe
between
communicates
program
let
anduser
usthese
respond
say
andactions
byto
from the event object. AWT provides two conceptual types of events:
Semantic and lowlevel events.
Semantic events:
These are defined at a higher-level to encapsulate the semantics of user
interface
component s model. Now let us see what are the various semantic event
classes and what
they
generate:
An Action Event object is generated when a component is
activated
An Adjustment Event Object is generated when scrollbars and
other adjustment
elements are used.
A Text Event object is generated when text of a component is
modified.
An Item Event is generated when an item from a list, a choice or
checkbox is selected.
Low-Level Events are the one that represents a low-level input
or windows-system
occurrence on a visual component on the screen. The various low-level
event classes and
what they generate are as follows:
A Container Event Object is generated when component are added or
removed from
container.
A Component Event object is generated when a component is
resized, moved etc.
A Focus Event object is generated when component receives
focus for input.
A Key Event object is generated when key on keyboard is
pressed, released etc.
A Window Event object is generated when a window activity, like
maximizing or close
occurs.
A Mouse Event object is generated when a mouse is used.
A Pain Event object is generated when component is painted.
object
An
event
object
occurs,
is passed
delegates
an to
event
a the
Listener.
object
task ofof
Ahandling
listener
the appropriate
must
an event
implement
type
to an
(asevent
illustrated
the interface
listener.
Event
when
below)
that
has
an
Listeners:
isthe
created.
methodThis
Applets
How Applets Differ from Applications :Although both the Applets and stand-alone applications are Java
programs, there
are certain restrictions are imposed on Applets due to security
concerns.
Applets don t use the main() method, while they are loaded
,automatically call
certain methods (init, start, paint, stop, destroy).
They are embedded inside a web page and executed in browsers.
They cannot r ead from or write to the files on local computer.
They cannot communicate with other servers on the network.
They cannot run any programs from the local computer.
They are restricted from using libraries from other languages.
The above restrictions ensures that an Applet cannot do any
damage to the local
system.
program in the same way you can run an executable file. At the time of
this writing, there
are three widely available Web browsers that can run Java applets:
Netscape Navigator version 2.02 or higher
Microsoft Internet Explorer 3.0
Java Soft Hot Java 1.0 pre-beta 1
These programs load applets from a Web page and run them remotely
on the Web user's
computer. This arrangement raises security issues that must be
handled by the Java
language itself and by Java-enabled browsers
Applet method
o
This is the first method to execute.It is the best place to define the
GUI
Components.
o
programming
The input
interface
streamand
class
a partial
is an implementation
abstract superclass
of input
that provides a
Input
streams.stream
minimal class
The InputStream
class defines methods for reading bytes or arrays of bytes, marking
locations in the stream, skipping bytes of input, finding out the number
of bytes available
for reading, and resetting the current position within the stream.
An input stream is
automatically opened when you create it. You can explicitly close
a stream with
the close method, or let it be closed implicitly when the
is garbage
InputStream
collected. Remember that garbage collection occurs when the
object is no longer
referenced.
JDBC
use it for non-Web applications, too. Of course, the exam targets the
Web, so the HTTP
protocol is the only one discussed in this blog.
Introduction
o Configuring backing beans and model beans so that they are instantiated
with the
proper values when a page makes reference to them.
o Defining navigation rules for each of the pages in the application
so that the
application has a smooth page flow.
o
Packaging the application to include all the pages, objects, and other
files so that
the application can be deployed on any compliant container.
Java interface
An interface in the Java programming language is an abstract type that
is used to
specify an interface (in the generic sense of the term) that classes
must implement. An
interface never contains method implementations . A Java class may
implement, and an
interface may extend, any number of interfaces; however an interface
may not implement
an interface. . A class that implements an interface must implement
all of the methods
described in the interface, or be an abstract class. Object
references in Java may be
specified to be of an interface type; in which case, they must either be
null, or be bound
to an object that implements the interface.inter face is a reference type,
similar to a class,
that can contain only constants, method signatures, and nested
types. There are no
method bodies.
Java Libraries
The Java class library is a set of dynamically loadable lib.. that Java
applications can call
at run time.
applications
provides
a comprehensive
cannot
Becauserely
theon
Java
any
setPlatform
of
ofthe
standard
platform-native
is notclass
dependent
libraries,
libraries.
on containing
a Instead,
specific
operating
the
common
Java
functions
Platform
tosystem,
modern operating systems.
They
o
provide the programmer a well-known set of useful facilities,
such
as container classes and regular expression processing.
oThe library provides an abstract interface to tasks that would
normally
depend heavily on the hardware and operating system, such
as network access and file access.
Some
o underlying platforms may not support all of the features a
Java
application expects.
The library
o
implementation can either emulate those features or provide
a
consistent way to check for the presence of a specific feature.
XML
In XML Extract and XMLX Path Reader you can configure the
validation your input
XML files by specifying the Xml features attribute. The Xml
features configure
validation of the XML in more detail by enabling or disabling specific
checks, see Parser
Features
PHP
Introduction
PHP is a server-side scripting language designed for web
development but also
used as a general-purpose programming language. PHP is now installed
on more than 244
million websites and 2.1 million web servers.Originally created by
RasmusLerdorf in
1995, the reference implementation of PHP is now produced by The
PHP Group. While
PHP originally stood for personal homePage, it now stands for php
hypertext
preprocessor, a recursive acronym
PHP code.is interpreted by a web server with a PHP
processor module, which generates the resulting web page: PHP
commands can be
embedded directly into an HTML source document rather than calling
an external file to
process data. It has also evolved to include a command-line interface
capability and can
be used in standalone graphical applications .
History
PHP development began in 1994 when the developer
RasmusLerdorf wrote a series
of Common Gateway Interface (CGI) Perl scripts, which he used to
maintain his personal
homepage. The tools performed tasks such as displaying his
rsum and recor ding
his web traffic. On July 13, 2004, PHP 5 was released, powered by the
new Zend Engine
.PHP 5 included new features such as improved support for
programming,
consistent
enhancements.
interface
the
In 2008
PHP
forData
PHP
accessing
Objects
5 became
databases),
(PDO)
the only
extension
stable
and numerous
version
(which defines
under a
object-oriented
lightweight
performance
development.
static
What
binding
is php?
and
had
Latebeen missing from PHP and was added in version 5.3.
Easy learning.
Php exception
PHP 5 has an exception model similar to that of other programming
languages.
An exception can beand
thrown,
caught within PHP. Code may be surrounded in
a tryblock, to facilitate the catching of potential exceptions. Each
must havetry
at least
one corresponding catchblock. Multiple
blockscatch
can be used to catch different
classes of exceptions. Normal execution (when no exception is
thrown within
the tryblock, or whenmatching
a catch the thrown exception's class is not present) will
continue after that last catchblock defined in sequence. Exceptions canthrown
within
be
a catch block.
Why php?
Ifmean
PHP
youallows
ismight
simple
already
easy.you
add
If
things
have
fact,
tosome
interact
like
PHP
a website
new
e-mail
and
with
HTML
features
forms,
and
yourare
are
visitors
or
tofamiliar
interchangeable
more
yourinelaborate
site,
ways
withits
HTML
HTML,
basic
things
within
alone
making
like
the
the
page!
appearance
created
can't.
shopping
step
This
While
with
tocarts
can
is
HTML.
still all
that save your past orders and recommend similar products. It can
also mean
social things like interactive forums and private messaging systems.
PHP is a lot easier to get started with than you might think. By learning
just a few
simple functions, you are able to do a lot of things with your website.
And once
you know the basics, there are a wealth of scripts available on the
internet that
you only need to tweak a little to fit your needs.
JavaScript
is a scripting language widely used for client-side web development.
It was the originating dialect of the ECMA Script standard. It is a
dynamic, weakly typed,
prototype-based language with first-class functions. JavaScript was
influenced by many
languages and was designed to look like Java, but be easier for nonprogrammers to work
with.
JavaScript, despite the name, is essentially unrelated to the Java
programming
language, although both have the common Csyntax, and JavaScript
copies many Java
names and naming conventions. The language's name is the result of a
co-marketing deal
between Netscape and Sun, in exchange for Netscape bundling Sun's
Java runtime with
their then-dominant browser. The key design principles within
JavaScript are inherited
from the self and Scheme programming languages.
HTML can also describe, to some degree, the appearance and semantics
of a document,
and can include embedded scripting language code (such as JavaScript)
which can affect
the behavior of Web browsers and other HTML processors.
INTRODUCTION TO DATABASE
This is the most crucial part of system design, in today s world the
quantity of
data stored in organization increases in an almost geometric
progression. The management
decision-making process depends on the quality and quantity of
information.
The objectives of database are Accuracy, Integrity and successful
recovery from the failure
privacy and security of data and overall performance. We have
designedi.e.
database
astaking
efficiency
system,
as apossible
system
whoseshort
overall
and long
purpose
term ismemory
to record
requirements
and
What is Database
consideration.
Database
maintains
information.
System
Basically
system?
? it is nothing more than a computer based record keeping
INTRODUCTION TO MYSQL
MYSQL is a relational data base and it is a part of the solution of LINUX
open
the
source evolution was
MYSQL
developed by TCX in 1996. They cr eated it because they
needed a relational database that could handle a large amount of data on
cheap hardware.
Mysqlitbased
why,
LINUX
is
has
and
thenot
system,
fastest
thealready
openrelational
though
source
caughtthere
product
the
database
are
attention
ports
was
now
practically
for
ofinindustry.
almost
market.
unknown.
ever
The
If ymysql
answer
plate is
forms
the
is in the
fastest
that
MYSQL
on
Uuntil
market.
and
primarily
1999,
good runs
NIX
Until the open source moment and the availability of UNIX based
operating system at
affordable price, no body looked at MYSQL as a contender.
Because of the popularity of Linux operating system MYSQL has
grown in market which
provided various users in market to use a relational data base language
license free with
many open source technology for development. As the PHP is a open
source server side
scripting language and use apache and Linux server to execute its
content, here the
MYSQL is a best relational database to use with open source PHP.
Why MYSQL:There are some points why to use MYSQL with PHP.
1. It is COST-EFFECTIVE.
2. It is QUICK and POWER FULL .
Database Connection Functions:
Description: PHP provides library for connecting the mysql database and
performing various operations in data base and associated tables.
Following are some functions provided by PHP for data base
connection and data
manipulation with query.
1. mysql_connect ():- Connect to the user s data base on particular host.
Syntax:-mysql_connect(hostname , user name, password);
Example:-mysql_connect(localhost , root , admin123 );
2. mysql_select_db ( ):- Selecting a particular data base of user.
Syntax:- mysql_select_db( database name);
3. Example:mysql_query():Syntax:-mysql_query(
mysql_select_db(customer);
mysql_query
sqlquery);
Executes
(SELECT
the*query
FROM USER);
4. Mysql_num_rows
Counts
():- the number of rows returned by mysql_query().
Syntax: - mysql_num_rows( $result);
Example: -
Conclusion
This training focussed upon increasing our knowledge and interest
in toward the
java.Because java is most interesting and most used language in these
days. We learnt
how to create a web sites and web pages.It was a great
experience.It increase our
practical skills that s the main yhing which we learnt in the training
session.Thus, we
believe that our project will be beneficial for various purposes & hence
our efforts will be
fruitful.
BIBLIOGRAPHY
Books:
1. Programming with JAVA (E Balagurusamy)
2. Mastering Enterprise JAVA( ED Roman)
3. Thinking in Java (Bruce Eckel)
4. The Complete Reference PHP 5 (Tata McGraw-Hill)
5. PHP, HTML, JS,MySql (Evan Bayross)
Websites:
Wikipedia about Java
http://www.PHP.net
http://www.google.co.in/