Java Basics(1)x - Govidya

yoinkscreechedInternet και Εφαρμογές Web

13 Νοε 2013 (πριν από 8 χρόνια και 1 μήνα)

456 εμφανίσεις

You can start your career in Java technologies first by learning the basics of java and some part of
advance java.

Some companies may provide you jobs if you have good hold on basics of java. You many get job in
swing or core java programming.

getting a good hold on java basics and the techniques of java programming you can start learning
advance java and enterprise java technologies.

The best way to start learning java basics is to download, install and start experimenting with the java

ome websites such as is providing Java Tutorials for beginners. These tutorials are
supported with code example that anyone can download and run on their computers.

So, this will save your time and you can learn java basics in no time.

So don
?t wait any more and start learning Java; visit our

Java Tutorials


Should you have java questions as at our

Java Questions



is great programming language for the development of enterprise grade applications. This
programming Language is evolved from a language named Oak. O
ak was developed in the early nineties
at Sun Microsystems as a platform
independent language aimed at allowing entertainment appliances
such as video game consoles and VCRs to communicate . Oak was first slated to appear in television
top boxes design
ed to provide video
demand services. Oak was unsuccessful so in 1995 Sun
changed the name to Java and modified the language to take advantage of the burgeoning World Wide

Java is an object
oriented language, and this is very similar to C++. Java Pr
ogramming Language is
simplified to eliminate language features that cause common programming errors. Java source code files
are compiled into a format called bytecode, which can then be executed by a Java interpreter.

If you are beginner read

New to programming


a) Java SE

Java SE (

Java Standard Edition


provides tools and API's to create
diverse applications. Applications developed with Java SE are supported by
operating system, including Linux, Macintosh, Solaris, and Windows.

b) Java EE

Java Enterprise Edition specifications

based on the foundation
framework of the standard edition. Java Enterprise Edition are the specifications
needed to service the multi
tiered environment, to support the enterprise class
service oriented architecture (SOA) and a lot...............

c) Java ME

Java Micro Edition

is an accumulation of Java APIs used to develop
devices applications like mobile phones, PDAs, TV set
top boxes, game
programming. The platform of micro edition generally consists of an easy user
interface, a robust security model and a wide variety of built
in networks for
running Java based application.

New to Java?

If you are

new to Java


and you want to learn Java and make career in the Java technology then this page is for you.
Here we have explained how to learn Java and master the Java technologies.

Java is a vast language and it requires a lot of effort to learn and master the necess
ary Java technology
to start your real life projects.

Here at RoseIndia.Net, we have developed hundreds of tutorials, examples and articles to help you learn
Java quickly and easily. We have tried to put support examples related to each Java technology th
at will
help you master the concepts.

These tutorials and examples are arranged in a sequence, so that you can learn Java step by step and
master the Java and JEE technologies.

Basics of Java Technology

This section provides an overview of Java technolo
gy as programming language and a platform. Java
technology is a simple, secure, robust, complete object oriented and platform independent high level
programming language.

It is also portable, high performance, multithreaded and networksavy that enable
in constructing software that can run along in small machines.

The whole technology is based on the
concept of

Java Virtual Machine

(JVM) that acts as a translators of

byte code into machine language. In
other words JVM converts the java byte codes into
platform specific machine language.

Understanding the Java Technology

Java technology is high
level, object
oriented, very robust programming language. Java is platform
independent programming language and you can run your compiled code on any operating sy
without recompiling your source code. Java technology is based on the concept of a single Java virtual
machine (JVM)

a translator between the language and the underlying software and hardware. All
implementations of the programming language must em
ulate the JVM, enabling Java programs to run on
any system that has a version of the JVM.

If you want to start java programming then you need to use a text editor to create and edit the source

By using the Java complier, you can change the source co
de into byte code. The byte code can be
run on any platform having Java interpreter that can convert the byte code into codes suitable for the
operating system.

Why Java Technology is so important?

This high
level powerful programming language provides a

powerful software platform as the JVM
installed on different platform understand the same byte code. This is ideal for server side web
programming and runs in a secured manner over internet. It enhance the computing power of the users
by taking merely fro
m desktop to the resource of the web. It contains JVM and Java Application
Programming Interface (API) that are kinds of readymade software components, and for using any
component, the need is just to import a related package in your program use the functi
onality. It offers
development tools that can be used in compiling, running, debugging and documenting the application,
making the Java programming fun and easy. The automatic garbage collection mechanism helps in
avoiding memory leaks and its coding takes

less development time than other programming languages
like C++.

Different Editions of Java Technology


Java SE


Java SE or Java Standard Edition provides tools and API's that you can use to create server
applications, desktop applications, and eve
n applets. These programs developed using Java SE can be
run on almost every popular operating system, including Linux, Macintosh, Solaris, and Windows.




Based on the foundation framework of the standard edition, Java Enterprise Edition helps in
application service, component model and enterprise class service oriented architecture (SOA).




Java Micro Edition or JME for short is an accumulation of Java APIs that are used for the
development of software for devices like mobile phones,
PDAs, TV set
top boxes, game programming.
The platform of micro edition generally consists of an easy user interface, a robust security model and a
wide variety of built
in networks for running Java based application.

Components of each edition

JSE Comp



It is the component architecture for J2SE platform and one can develop and assemble
these software programs for better web application. It is a reusable software component that can be
manipulated visually in a builder tool. This software assists visual b
uilder tools in using reflection,
introspection, and also analyze and customize JavaBeans.

Java Foundation Classes (JFC)


It is a part of Java class libraries based on the Java platform used for
developing graphical user interface (GUI). JFC helps in 2D
graphics, imaging, text formatting and printing
with the help of Abstract Window Toolkit (AWT), Swing and Java2D. With the help of input method
framework, the JFC technology assists in preparing application that can be accessible to all users around
the wo
rld in different languages. Drag and Drop is another feature of JFC that supports data transfers
between different Java applications.



It is a platform independent and a feature oriented software system that offers developer an
automated help co
mponent. JavaHelp 2.0 API is useful while building online documentation and
presenting online information to the application users.

Java Web Start


It is framework in the Java platform that assists in starting Application software directly
from the inter
net by using a web browser. As we know Java applet can run in a browser but in case of
Java Web Start, it doesn't run inside and solve many complex problems associated with Java

JVM. It also provide many classes that in turn provides various ser
vices and allow better access to
resources. Version 1.0 was introduced in the year 2001. Now with the release of J2SE 1.4, Java Web
Start is included with Java Runtime Environment and does need any separate installation.

Java Database Connectivity (JDBC)


JDBC API is a part of Java Standard Edition that helps in
accessing data from a SQL based database. Besides, it also process the result and allows in using the
programming language with "Write Once, Run Anywhere" feature. Some of its key features are li
ke full
access to metadata, no special installation and database identification.

Java Media Framework (JMF)


Its an advanced API that allows Java developers to process and add
video source to Java application and applets. It is useful for multimedi
a developers to capture,
playback, transcode different media formats.



Enterprise JavaBeans (EJB)

This technology is a server side component of Java platform

used for the
construction of enterprise application. It is one of the Jav
a APIs attached with the enterprise edition. By
using Java technology, EJB helps in quick development of small, distributed, transactional and secure



This JavaMail API technology allows to build mails and messaging application in a

independent and protocol independent framework. It is both a part of JSE and JEE platform. Thus,
JavaMail uses an extensible platform for transferring all kinds of Multimedia Internet Mail Extension

Java Message Service (JMS)


under Java community process, JMS technology is used for
sending messages between users. Basically, it

is an enterprising messaging tool used for building
enterprising application. The JMS API is a combination of Java technology and enterprising messagin
that provides facilities for building small message based application. It functions under two models:


Publishing & Subscribing


JavaServer Pages (JSP)


The JSP technology enables web developers in developing and maintaining
web content pages in formats like HTML and XML. With the help of JSP, it becomes very easy to build
server and platform independent web based application. This uses HTML and XML tags

that offers logical
solution for the content. This separately user interface and content development from each other, which
allows the designer to change page layout without changing the content.

Java Servlets

This enables a developer in adding content
to a web server by using Java platform. This
provides the mechanism for enhancing the functionality of web server. In short, servlets provides platform
independent and component based web based application without the performance limiting of CGI



Connected Limited Device Configuration (CLDC)

It is one of the configurations of Java Micro Edition.
'Configuration' describes minimal features of a complete Java. The CLDC specifies the capabilities of
JVM, the base set of API for re
source limited devices like pager and mobile phones. There are two
version of CLDC: version 1.0 was released in 2000 and came to be known as Java Specification Request
(JSR)30. Later version 1.1 or JSR 139 but 1.0 is more widely used. The Connected Limited

Configuration and the Mobile Information Device Profile (MIDP) together provides solid Java platform for
developing application to run on less processing power devices.

Mobile Information Device Profile (MIDP)


This is another configuration of J
ava Micro Edition and
coupled with CLDC, it provides a farm Java Runtime Environment for various mobile devices and other
personal digital assistance (PDA). With the help of MIDP, developers can develop application once and
then redistribute them into vari
ous mobile information devices in a very small period of time. Its principal
functions include the user interface, network connectivity data storage and overall application process
management. There are two versions of MIDP: one is MIDP 2.0 or JSR 118 and
the second one is the
MIDP 1.0 or JSR 37.

Connected Device Configuration (CDC)

Developed under the Java Community Process (JCP), it is a
standard framework of Java technology used for building and delivering application that can be shared in
a wide ra
nge of networks and devices ranging from pagers, mobile phones, set top box and other PDA
devices. It is in two versions: the JSR 36 (CDC 1.0) and the latest one is the JSR 218 (CDC 1.1).

What should be my learning path:


Learn Core Java


The Core Java Technology is the foundation of Java Platform of JSE. It is
used in all classes of Java programming from desktop to Java Enterprise Edition. This include

Java APIs,
Java Application, JVM, JavaBeans, JavaScript, JSP etc.


Learn JSP


JSP technology assists developers in generating HTML, XML web pages. It uses
Java code and some predefined actions while

creating web content. This helps in the creation of
JSP tag libraries that acts as extensions to HTML and XML tags.


Learn Servlets


In a Java Platform, Servlets assists developers in ad
ding content to a web
server. Servlets with Java server pages acts as a competitor to various dynamic web content
technologies like CGI, ASP.NET, JavaScript etc.


Learn about Tomcat and other servers


Developed by Apache Software Foundation Tomcat is
a J
ava based web application server used to run Servlet and JSP. It is not merely limited to
application server and provides an open platform to develop extensible web and content
management service.


Learn Open Source technologies





Basically in Java there are
three open source technologies known as frameworks; these are Spring, Hiber
nate and Struts.
These open source application frameworks solves many problems related to JSE and J2EE, and
helps in effective development of web application.


Learn EJB


Enterprise Java Beans are a par
t of J2EE and also a server sided component used
mostly in large projects. It helps in easy and rapid development of distributed, transactional and
small application based on Java technology.


Learn about Database Management System


It is a software desig
ned to manage and run a
database. Generally, it is used in company back office work, accounting, customer support
system and several other purposes.

What is the use of java?

Java technology is a high
level programming and a platform independent language.

Java is designed to
work in the distributed environment on the Internet. Java has a GUI features that

provides you better
"look and feel" over the C++

language, moreover it is easier to use than C++ and works on the concept
of object
oriented programmin
g model. Java enable us

to play online games, video, audio, chat with
people around the world, Banking Application, view 3D image and Shopping Cart. Java find its extensive
use in the intranet applications and other e
business solutions that are the grass
roots of corporate
computing. Java , regarded as the most well described and

planned language

to develop an applications
for the Web.

Java is a well known technology which allows you for software designed and written

only once for an

"virtual machine"
to run on a different

computers, supports various Operating System like Windows PCs,
Macintoshes, and Unix computers. On the web aspect, Java is popular on web servers, used

by many of
the largest interactive websites. Java is

used to create standalone a
pplications which may run on a single
computer or in distributed

network. It is also be used to create a small application program based on
applet, which is further used for Web page. Applets make easy and possible to interact with the Web


ferred Over Other Languages

The Java is a high
level programming language

that can be supported by all of the following features:



Object oriented










advantages over other languages and environments that make it suitable for just about any
programming task.

The advantages of Java are as follows:

Java is simple, easy to design , easy to write, and therefore easy to compile, debug, and learn
an any other programming languages.

Java is object
oriented, that is used to build modular programs and reusable code in other

Java is platform
independent and flexible in nature. The most significant feature of Java is to run
a program easily

from one computer system to another.

Java works on distributed environment. It is designed to work on distributed computing , Any
network programs in Java is same as sending and receiving data to and from a file.

Java is secure. The Java language, compil
er, interpreter and runtime environment are


Java is robust. Robust means reliability. Java

emphasis on

checking for possible errors, as Java
compilers are able to detect many error problem in program during the execution of respective
m code.

Java supports multithreaded. Multithreaded is the path of execution for a program to perform
several tasks simultaneously within a program. The

java come with the concept of Multithreaded
Program. In other languages, operating system
specific proc
edures have to be called in order to
work on multithreading.

Java Technology Works

Java is a high
level programming language and powerful software platform. On full implementation of the
Java platform gives you the following features:

JDK Tools
: The JDK to
ols provide

compiling, Interpreter, running, monitoring, debugging, and
documenting your applications.

The main tools used are the


compiler, the

and the


documentation tool.

Application Programming Interface (API)
: The API prov
ides the core functionality of the Java
programming language. It gives a wide collection of useful classes, which is further used in your
own applications. It provides basic objects and interface to networking and security, to XML
generation and database a
ccess, and much more.

Deployment Technologies
: The JDK software provides two type of deployment technology such
as the Java Web Start software and Java Plug
In software for deploying your applications to end

Graphical User Interface Toolkits
: The
Swing and Java 2D toolkits provide us the feature of

Graphical User Interfaces (GUIs).

Integrated Libraries
: Integrated with various libraries such as the Java IDL API, JDBC API, Java
Naming and Directory Interface TM ("J.N.D.I.") API, Java RMI, and Java
Remote Method
Invocation over Internet Inter
ORB Protocol Technology (Java RMI
IIOP Technology) enable
database to access and changes of remote objects.

Java Technology Changes

Our Life

Easy to Start

Since Java programming language is completely based

language, it's easy very simple and easy to learn, especially for programmers already known with
C or C++.

Easy to write code
: As compared to program metrics (class counts, method counts, and so on)
tell us that a program written in the

Java programming language can be four times smaller as
compare to the same program written in C++.

Write better code
: The Java programming language encourages good coding practices, and
manages automatic garbage collection which

helps you avoid memory le
aks. Based on the
concept of

object orientation, its Java Beans

component architecture, and

range, easily
extendible, flexibility and API

can reuse existing, tested code and introduce fewer bugs.

Develop programs and Time Safer
: The Java
programming language is easier and simpler than

as such, manages your development time

upto twice as fast when writing in it. The
programs will also require fewer lines of code.

Platform Independencies
: The program

keep portable and platform indepe
ndent by avoiding
the use of libraries written in other languages.

Write Once and Used in any Java Platform

: Any Source code of Program

are written in the
Java programming language, that is compiled into machine
independent byte codes and run
ly on any platform of java.

Distribute software makes work easy

: Using Java Web Start software, users will be able to
launch own applications with a single click on mouse. An automatic version check initially

weather users are always up to date with the
latest version of your software. If an update is
available for it, the Java Web Start software will automatically update their installation.

Java Platform


is cross
combination of

hardware or software environment in which a program runs. We are

known with

the most popular platform like Microsoft Windows, Linux, Solaris OS, and
Macintoshes OS. The Java platform differs from other platforms, that is only software
only platform which

runs on other hardware
based platforms.

The Java platfor
m has two components:

The Java Virtual Machine(JVM)

The Java Application Programming Interface (API)

The Java Virtual Machine is the root for the Java platform and is integrated into various hardware

The API is a vast collection of

s software components that provide you many useful functionality to
the application. It is grouped into logical collection

of related classes and interfaces; these logical

are known as packages.

The API and Java Virtual Machine insulate the
program from


Java work on platform
independent environment, the Java platform is bit slower than native code.
However, new changes

in compiler and virtual machine

brings performance close to that of native code
without posing any threatening t
o portability security.

All source code is

written in

text files (Notepad Editor) save with the


extension in the Java


The source files are compiled into


files by the


compiler. A



contains byte codes
the machine

language of the Java Virtual Machine (JVM). The


launcher tool

runs your
application with an instance of the Java Virtual


Schematic Flow of Java Software Development Life Cycle

JVM works on different Operating System . The



capable of running on various
Operating System. There are some virtual machines, such as the Java Hotspots virtual machine that
boost up your application performance at runtime . This include various tasks such as Efficiency of
amme and recompiling (to native code) which is

frequently used sections of code.

Java JVM, the same application is capable to run on multiple platforms.

How to Java Program

If you are beginner in java , want to learn and make career in the Java technolo
gy , this is best the page

for you. Here we have explained how to learn Java and become a master of the Java technologies.

Java is a high
level Programming

language that requires a lot of effort and work to learn and master on

necessary Java technology
to begin your real life projects.

We here tried to give you a example, that helps you in understanding java technology more easier and

Basic On Java

As we Know Java is based on the concept of Object
oriented Programming language. It is a simple,

secure, robust, multithreaded, portable, platform independent high level programming language. This
feature of Java helps us in making a program that can run independently along in small machine. The
Java Technology is completely based on Java Virtual Mac
hine(JVM).The JVM act as Translator that
convert the byte code into machine language which is a readable one.

Understanding Java Technology

Java is Platform independent language that you can run your compiled code on any operating without
recompiling the s
ource code. For a Beginners, want to start on java Program, then you need a notepad
editor which is used to edit your java source code in it. Using a Java Compiler you can translate the
source code into byte code. The Java Compiler is used to check the Syn
tax error in your code. Java has
a number of compiler like JDK1.5,JDK 5.0 etc.If your code contains error then, Compiler show the error
message on your command prompt. Otherwise, it convert the source code into byte

code with extension
.class file. We are
already known with

Java virtual machine (JVM) on which java Technology based on. It
acts as translator and interpreter between the language and the underlying software and hardware. The
JVM act as

interpreter that

convert the byte code into suitable cod
e for the respective operating system.

Java Program for Beginner

Our first application will be simple and easy. The Program

"the Good Morning India" Application is written
in Java language. Write it into a Notepad Editor or copy it in your web browser, an
d save


a file named
as Good Morning India.

java. This program

shows the

output function of

programming language by
displaying the message "Good Morning India!". Java compilers check the filename and

match the class

Let Us Start With the Basic

Programming Code

A java Program begins

with public class Good Morning India. Inside the Class, we declare Static void
main function(String args[]) .To call a method that is object independent ,static method is called. we don't
need to create the object o
f class or class is to be instantiate, The System.out.println is used to display
the output on the Console System.

Source Code

In Text/Notepad editor, create a file name Good Morning India. java with the following contents:

class GoodMorningIndia


public static void main (String args[]) {

System.out.println("Good Morning India!");

//Displays the output String on
the Command Prompt//




Displays "Good Morning India!" to the standard output.

**/ (Comment)

To Compile this Program
we need Javac Compiler, Before working on any

core java applications, you
need to download and install the Sun


tools known as Java Development Kits.

Before Compiling on a Command Prompt We need to set the Class Path in the Environmental Variable
perty of My Computer or set in the Command Prompt. For the sake of Convenience, We set the Class

in Environmental Variable Property

such that we don't need to write repeatedly the same path

command prompt for executing the application again and

Set Class Path =C:

Class Path variable is only the

way to tell applications, including the Java Development tools kits, where
to look for user classes.

After Setting the Class Path ,We compile the Program code using

Javac Good Morning
India. java

Since Java is a Case sensitivity in

which words can be differ in meaning based on

use of different
uppercase and lowercase letters.So,be make sure the Program code should be same typed in your
Command Prompt

as you have saved your program i
n Notepad Editor.

If the Compilation is error free, The java return you on the Command Prompt and create a folder of Good
Morning India. class file where you have saved the program in the respective directory. Once the
Program is in this form, it is ready
to run. Otherwise, Check the class file is created or not. In case it has
been not created, the Compiler show the error message on Command Prompt and check the further error
in your Syntax of programming code.

To Run this Program code

Java Good Morning


Command Prompt display the Output

Good Morning India!