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


Introduction to Java

Previous Next



Getting Started With

Applications and Applets are the most common Java programs. like HotJava browser, Applications are stand-alone programs. Applets are similar to applications, but they adhere to some sets of conventions which allow them run within a browser which is Java-compatible.




"Hello World" Application Program

By following the steps given in the page below. you can do create and also use a standalone Java application.

Create a file named AppHelloWorld.java with the Java code shown here:
class AppHelloWorld
{
public static void main (String args[])
{
System.out.println("Hello World!");
}
}




Compile the given source file

Using Java compiler compile the source file. If the compilation succeeds, then the compiler creates a file called AppHelloWorld.class. If compilation fails, make sure what you have typed in and what name you have given.




Run the application program

Using the Java interpreter run the program. You will see "Hello World!" displayed on your standard output screen.




"Hello World" Applet

By following the steps given here, you can create and use applet. When you have followed all the steps, your directory/folder structure should look something like a tree as shown here:




Create a directory

Create a directory that can hold your HTML pages. and do this only if you have not created any.
note: If you want to reload the applet do NOT invoke the hotjava (or any other applet viewer) from the HTML directory. Because of the way the class loader do work, an applet cannot be reloaded (for example, after making changes to its code) when you invoke applet viewer from the directory which is having the applet's compiled code.




Create the Java source file

Create a file named HelloWorld.java in the HTML directory with the Java code shown here:

import java.awt.Graphics;
public class HelloWorld extends java.applet.Applet
{
public void init()
{
resize(150,25);
}
public void paint(Graphics g)
{
g.drawString("Hello world!", 50, 25);
}
}




Compile your source file

Compile your source file using Java compiler. If the compilation succeeds, then compiler creates a file called HelloWorld.class. If compilation do fails, make sure you typed in and have named the code exactly as shown above.




Then Create an HTML file that includes applet

Create an HTMl file Hello.html containing the following text in your HTML directory:

<HTML>
<HEAD>
<TITLE> A Simple Program </TITLE>
</HEAD>
<BODY>

Here is the output of our program:
<br> <APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
</APPLET>
</BODY>
</HTML>




Loading an HTML file

Load the new HTML file into HotJava by entering the file's URL in the Document URL field near to the top of the HotJava window, as shown below:

file:/home/academic-tutor/HTML/Hello.html

Once the you successfully completed these steps, you should get the following in the HotJava page that comes up:

Here is the output of our program:

Hello World!





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: introduction to java tutorial, java language, introduction to java programming, introduction to java a programming language


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.