Applications vs Applets
Home ] Up ] Why Java? ] History of Java ] Java Design Goals ] Java vs C/C++ ] [ Applications vs Applets ] Java and the Internet ] Common Java Misconceptions ]

 

 

Java can produce two different kinds of programs (actually, there are more kinds, but these are the two we'll talk about in this course):

Applications

  • An application is a 'normal' program.
  • Can be essentially any program you want.
  • Can do anything you wish
  • Is in control of itself.
  • If you write it in Java, porting should be easy, possibly trivial.

Applets

  • An applet is a program that runs on Web pages.
  • Provides 'dynamic content' to the page.
  • Requires a Java-enabled browser:
    • Netscape 2.0 and beyond
    • Microsoft Internet Explorer
    • Sun's HotJava browser
    • Mozilla
    • Mozilla Firefox
    • Opera

    (Note that these days, you need to use the Java Plug-in to support up-to-date Java versions.)

  • Typically downloaded from a host site somewhere on the Web.
  • Simple applets are untrusted code, and therefore are:
    • Not allowed to access local file system:
      • Read, write, rename or delete files
      • List directories
      • Check for file attributes (existence, size, dates, etc.)
    • Not allowed to perform networking operations:
      • To or from any host other than the one from which the code was loaded.
    • Not allowed to use certain system facilities:
      • Exit the Java interpreter
      • Spawn new processes
      • Dynamically load native code libraries
    • Not allowed to make use of certain AWT facilities:
      • Initiate a print job
      • Access the system clipboard
      • Access the system event queue
    • etc...
  • Restrictions enforced by the Web browser and the Java Virtual Machine.
  • Local applets may find these restrictions relaxed.
  • JDK 1.1+ makes it possible to circumvent these security restrictions:
    • By "signing" an applet -- that is, placing all the code in a JAR file, and attaching a digital signature to that JAR file.
    • Signing an applet is performed using the javakey tool
  • Each subsequent version of the JDK has provided increasingly more flexible and finer-grained controls over these security restrictions.

 

This page was last modified on 02 October, 2007