Home | Java Menu | Java Applets | Java Tips | E-mail Us
Questions and Answers
What is Java?
What is the difference between Java applications and Java applets?
What is the difference between Java and JavaScript?
Can Java and JavaScript run together?
What do I need to compile and run Java applets?
What is Swing?
Where can I find good Java documentation?
  E-mail us a question
What is Java?
Java is an object-oriented programming language developed by Sun Microsystems that has been designed to run on any platform with a Java virtual machine. Java enables you to write programs called applets that you can embed in Internet Web pages, and it allows you to write applications programs that you can run normally on your computer that supports the language.

There are many advantages of using Java:
  • Java is machine independent and more portable than any other language. A single set of source code can run unchanged on any computer that supports Java.
  • Java is object oriented which means programs are written using objects that are specific to the problem being solved. This makes it much easier to maintain and extend.
  • Java has security restrictions already built in. You can download a Java applet, run it on your computer, and it will not cause damage to your system.
  • Java is multithreaded. It has the capability for a program to perform several tasks simultaneously within a program.
  • Java is dynamic. It was designed to adapt to an evolving environment. You can freely add new methods and properties in a class without affecting other programs using the same class.
What is the difference between Java applications and Java applets?
Java application is an ordinary standalone program.

Java applet is a program that is embedded in a Web page.

Applets that are loaded over the network have several security restrictions:

  • An applet cannot ordinarily read or write files on the computer that it is executing on.
  • An applet cannot make network connections except to the host that it came from.
  • Despite these restrictions, applets can invoke the public methods of other applets on the same page.
What is the difference between Java and JavaScript?
Java is a programming language developed by Sun Microsystems. With Java, you create fully standalone programs that go through a process of writing, compiling, and being referenced in your Web page.

JavaScript is a programming language developed by Netscape. With JavaScript, you type the code into your Web page just like HTML tags and text.
Can Java and JavaScript run together?
Yes, you can implement both Java and JavaScript on the same Web page.
What do I need to compile and run Java applications and applets?
In order to compile Java programs, you need to
download and install the Java Development Kit (JDK) from the http://java.sun.com web site following the installation instructions.

JDK consists of a set of separate programs, each of which is invoked from a command line. Besides JDK, there are other Java development packages on the market today. The major development tools are:These tools provide an integrated development environment (IDE) for rapidly developing Java programs.

Java source code is always stored in files with the extension
.java. Once you have created the source code for a program and saved it in a .java file, you need to compile the source code. Using the compiler that comes with the JDK, you would do this with the following command:  javac MyProgram.java
  » 
javac is the name of the Java compiler.
  » 
MyProgram.java is the name of the program source file. <HTML> <HEAD> <TITLE>My First Applet</TITLE> </HEAD> <BODY> <APPLET CODE="MyProgram.class" WIDTH="200" HEIGHT="300"> </APPLET> </BODY> </HTML>   » The code between the <APPLET> and </APPLET> tags specify that the byte codes for the applet are contained in the file MyProgram.class which is specified as the value for the CODE attribute.

If you save this HTML page specification in the file
MyProgram.html in the same directory as the Java applet code, you can run the applet using appletviewer from the JDK with the command:  appletviewer MyProgram.html

You can also use your Java-enabled Web browser to view your applet in a Web page.
What is Java Swing?
Java Swing Components are part of the Java Foundation Classes (JFC), which encompass a group of features to help people build graphical user interfaces (GUIs). They include everything from buttons to split panes to tables and give any program a choice of looks and feels. For example, the same program can use either the Java look and feel, the Windows look and feel, or the Macintosh look and feel. "Swing" is the package names for the Swing API, which begins with javax.swing.

Using Swing components is recommended over using AWT components. Swing components start with J which make them easy to identify. For example, the AWT button class is named Button, while the Swing button class is named JButton.

Some Swing components capabilities include:
  • Swing buttons and labels can display images instead of, or in addition to, text.
  • You can easily add or change the borders drawn around most Swing components.
  • You can easily change the behavior or appearance of a Swing component by either invoking methods on it or creating a subclass of it.
  • Components do not have to be rectangular.
Where can I find good Java documentation?
Java 2 Platform, Standard Edition, v1.2.2 API Specification
Sun Microsystems' Java Technology Home Page

Beginning Java 2 by Ivor Horton
Paperback - 1109 pages 2nd edition (February 1999)
Wrox Press Inc; ISBN: 1861002238
List Price:  $49.99
amazon.com Price:  $39.99
Read book reviews


Java Programmer's Reference
by Grant Palmer
Paperback - 1200 pages 1st edition (March 2000)
Wrox Press Inc; ISBN: 1861004222
List Price:  $34.99
amazon.com Price:  $27.99
Read book reviews
Java Applets
Date and time
Image animation
Window status message on mouse over images
Using the <PARAM> tag to collect user arguments
Graphical User Interface (GUI) - buttons, labels, checkboxes, and text areas
Multimedia using sound
Multimedia using image
Application and Applet combined
Running threads
Java Tips
Do's and Don't
Common Problems
Programming Standards
Home | Java Menu | Java Applets | Java Tips | Legal
© 1999-2003 Complete e Solutions, Inc.