Java Applications and Applets
Introduction.
For our first semester we will focus on developing Java applets and/or
applications. Next semester we will get involved more in JSP and
Servlets. There are even more differences between applets and
applications that will become more apparent as we go through the
semester. But remember,
applets have been designed to be invoked by a client's browser on the web
applications are going to be run as stand-alone programs on someone's computer
So Java isn't just for developing applets. It is also important to remember that getting applets to work from the web through the client's can be much more difficult than advertised in the Java hype. Compilation and Interpretation. In order for Java programs to obtain platform independence Java code is not compiled into an executable. Java compilers actually create what is called bytecode. This bytecode is found in what are called class files.
Java bytecode is then interpreted at run time by something on a particular computer. How this is done depends on the program. For example, it may be done with a JVM - Java Virtual Machine within a browser. Though we have all probably heard that different browsers and different corporations versions of Java Virtual Machine can cause some difficulties! Application or Applet? Now for the big, not entirely well-defined, question. According to Deitel & Deitel, an application is a program that executes in the command window. In Windows, depending on your version, this is the MS-DOS Prompt or Command Prompt environment window.
It is certainly possible to improve on this interface both from the point of view of you as a developer and a user. The Java Swing class has a number of built-in objects we will quickly use to improve interactivity with the user. On the other hand, for an applet, the steps are slightly different.
We will now work examples of each type in class and then develop them further throughout the semester. Working in the Command Window. Your are likely to be unfamiliar with moving around in a command line environment. First you need to access either the MS-DOS Prompt or the Command Prompt. You should get a window that looks something like the following. |
At this point you need to move to the directory where
you have the program files. One way to move back towards the root
directory on the C: drive is to type cd .. This will move you one directory back towards the root \ as illustrated in the following image. |
You are likely to realize that you would like to move
more quickly to the directory you desire. The following command will
move me to my JavaP directory off the root, into its subdirectory called
MessageBoxes. cd \JavaP\MessageBoxes This is illustrated in the following image. |
While there are many other commands you could give at
the prompt, including those to compile and or execute Java programs, you
may want to list the files in this directory. This is done with the
following command. dir This is illustrated in the following image. |
We won't spend any more time on command line commands in Windows. These few will suffice, though there are others and there are modifications of these. |