Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

Java Tutorial
Java Introduction
Object Oriented Programming Concepts
Anatomy of a Java Application
Syntax and Semantics of Java
Java Objects, Classes, and Interfaces
The String and StringBuffer Classes in Java
Setting Program Attributes in Java
Using System Resources in Java
Threads of Control in Java
Errors and Exceptions in Java
Java Input and Output Streams
Overview of Java Applet
Creating an Applet User Interface in Java
Communicating with Other Programs in Java
Overview of the Java UI
Using GUI Building Blocks in Java
Laying Out Components within a Container
Working with Graphics in Java
How Java Differs from C and C++
Java Summary

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


Anatomy of a Java Application

Previous Next



Anatomy of a Java Application

Java programs which do run within a browser which is Java-compatible are known as applets. Here we have discussed about the components of a stand-alone Java program, that is, a program written in the Java language which can run independently of any browser. Stand-alone programs in Java are also known as Java applications. The following application "DateApp" displays the current time and date.

import java.util.Date;
class DateApp
{
public static void main (String args[])
{
Date today = new Date();
System.out.println(today);
}
}




Import statement

As we can see the first line in the program imports the Date class from the package called "java.util". By importing we can make that class available to the file into which it has been imported. A "java.util" package is a collection of classes that do provide miscellaneous functionality. The "Date" class from the java.util package allows you to manage and also manipulate calendar dates in system independent way.




How to Define a Class

In Java language, the general form of class definition is as shown below

class name
{
. . .
}

The keyword class begins the class definition for a given classname here it is "name". All variables and methods of the given class are held inside the curly brackets that begins and ends the definition block of a class. In the class "DateApp" has no variables and has only one method called main().




Method: main()

main() method is called the brain of the Java application.you need to specify the name of the class which you want to run while running a Java application using the Java interpreter. Interpreter will do invokes the main() method defined in the class. The main() method will control the program flow, allocates all the resources which are needed, and will run any of the methods that do provide the functionality to the application.




Using Objects in the Programs

The first line in the method "main()", will declare, initialize and instantiate an object called "today". The default constructor is used to initialize today, that initializes the object new Date to contain the current time and date. In the second line of the method "main()" uses dot operator to refer to the class's or object's methods or variables. The above code illustrates the uses of instance variables and methods and class methods and variables




How to Save, Compile and Run an Application

To create and edit Java program, you can make use of any editor or word processing program. Java programs should be saved with the .java extension, so using any ASCII editor, write the program exactly as it appears in this page and save the program with the file name DateApp.java.

After creating your Java program, you should compile the program using the Java compiler before running it When a Java source file is compiled, the compiler creates a .class extension file in the folder in which the source file is stored. The compiler will name the resulting .class file after the class is defined in the source file. For example, when you compile the "DateApp" class which you have created above, the compiler will name the resulting class file "DateApp.class" after the class, with regardless of the name of the source file. Even if you would save the DateApp class as Wow.java, the compiler would still create a file called "DateApp.class".

After compilation, using the Java interpreter you can run the application . The program must display the current time and date.




Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previous Next

Keywords: java system application server, free mobile java application, iden web java application, java application loader, java system application server platform edition, iden java application loader, video in a java application, free java application for nokia 6125, types of java application, java technology downloads application server


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.