Symantec Café gives developers the ability to create interactive programs and embed them into Web pages on the Internet more easily. Because these programs are developed in Java, they will run without modification on any machine supporting Java runtime virtual machine. Café also enables you to create stand-alone applications and deliver the applications to any of the environments that support Java programs. This platform independence and the ability of the Java applet to communicate over the Internet has caused an explosion of interest in Java and Symantec Café.
Today we are going to discuss how to install and use Symantec Café. On the outside, Symantec Café might not look like the Java Development Kit, but Café is more or less designed as a wrapper, notwithstanding some things such as a native compiler that is strictly owned by Café. Symantec Café's overall focus is to provide a professional integrated development environment that enables the user to take advantage of the power of Java's object technology. Coupled with a professional development environment and a completely customizable front end, Symantec Café is one of the most powerful Java development tools in the industry. This section walks you through installing Symantec Café version 1.0. If you are installing version 1.2, check the 1.2 documentation for more information.
Unlike some of the other IDEs in the industry such as Borland's Java add-on and Sunsoft's Java Workshop, Symantec Café is designed specifically for the Windows 95/Windows NT platform. The result is a much more stable and much faster development environment. Officially, Symantec says that Café can run on a 386 system with 8M of RAM. However, based on the testing done for this book using Symantec Café on machines from a 486 to a Pentium Pro, it is recommended that you have 16M of RAM with a Pentium processor. Depending on the cluster size of your hard disk and the installation options you choose, Café takes from 25M to 60M of hard disk space.
| Warning |
Symantec Café 1.0 and 1.2 do not officially support the Windows NT 4.0 operating system because it is still an unreleased product. In most cases, however, it will work. One thing to look out for is that NT 4.0 does not have the DLL ctl3d32.dll that Windows NT 3.51 comes with. Café uses this system DLL and assumes that it already is installed on your system. However, if you go to the following Web site, you will receive instructions from Symantec on how to download the DLL and install it in your system directory: http://cafe.symantec.com/cafe/technotes.html If you do not have access to the Web or you have the Symantec Café on CD, you can look for the DLL in the ..\redist32 subdirectory. |
The version of Symantec Café that is available at software stores comes only in CD form. If you do not have a CD-ROM, you can purchase it online from Symantec's Web site through a secure transaction and download it to your system:
http://www.onanalysis.com/symcorp/cafe/
The size of the compressed file to be downloaded is about 14M.
| Note |
| Symantec Café 1.0 uses several environmental variables (e.g., CLASSPATH) that are placed upon installation in your autexec.bat. Café 1.2, however, doesn't require any of these variables except PATH. If you are upgrading to version 1.2, you can remove these environmental options. |
If you are running Windows 95 or NT 4.0, the Café CD will automatically load the setup program. However, if for some reason it does not, then your first step in the installation of Café is to execute setup.exe. After you have started the setup, the first window you should see is shown in Figure 2.1.
Figure 2.1 : Installing Symantec CafÈ.
Click the Next > button and you will see the next step in the setup. Figure 2.2 shows a list of available components. For material that is covered in the rest of this book, it is preferred that you install all of the options. However, if you really are pressed for disk space, the only option that you must install to do the examples in this book is the Café Program Files option.
Figure 2.2 : Installation options for Symantec CafÈ.
Click the Next> button and you will see several pages that contain license agreements. Obviously, it is up to you whether to agree to these terms or not. If you choose not to agree, your setup will be aborted. Assuming that you agree, click the Agree button for the next two windows. After the licensing pages, the next window that you will see asks you to specify the name of the program folder where the Café icons (or shortcuts, according to Windows 95 jargon) will be located.
| Note |
In Windows NT 3.5x, this step will display the program group you want to install the Symantec Café icons in. |
The final window, shown in Figure 2.3, gives a brief overview of where the Café source files are located and where these files will be placed.
Figure 2.3 : Summary of source and destination directories for your installation of Symantec CafÈ.
By clicking Next >, you're done! Symantec Café will be installed to the specified location. The final step is that Symantec Café will request to restart your system in order to finish the installation process. Once you have successfully restarted your system, you will have completed the installation of Symantec Café and can start developing Java programs.
Obviously, whenever you install software you should be able to uninstall it as well. For Windows 95 users, Symantec Café uses the InstallShield wizard, which means that Café will be added to the Add/Remove Programs option in the Control Panel. Also, for Windows NT users, Symantec Café will place an extra uninstall icon that gives you the ability to remove the software. As with all products using InstallShield, it only will remove the files that were originally copied when you installed the program. Any files that you created-directly or not-that are in the same directory as Café will remain behind after the product has been uninstalled.
This section is designed for you to become oriented with the Café desktop. If you have never used a professional IDE this might appear intimidating, especially with all of the tools and options that are available to the application. As you work with Café in this book, you will begin to appreciate why the developers of Café designed it the way they did. Also with Café just about everything is customizable. Not only does that give you greater flexibility as you work, it also keeps everything at your fingertips. Furthermore, the actual environment where you write the code for your program uses a highlighted color development environment so that keywords appear in one color and comments in another. Also, Café has a Studio that allows you to drag and drop front-end components, making it easy to develop front ends in Java. This Studio sports a Visual Basic-type design environment with a toolbox containing the components. On the back end, Symantec Café automatically generates the actual code for the front end that you designed in the Café Studio. Looking deeper under the hood in Symantec Café we see that it uses its own version of a Java compiler that runs much faster than the traditional compiler that comes with the Java Development Kit. Also, Café contains a faster interpreter that also enhances the execution speed of your compiled Java programs.
| Tip |
As you work with Symantec Café, experiment on everything with your right mouse button. Café was designed for the Windows environment, so it usually will support a menu of shortcuts and tools specifically related to whatever you clicked. |
When you start Café for the first time it should look very similar to Figure 2.4. Note that everything is well-organized and space is optimized so that there is very little unused space on your screen. This is done dynamically by Symantec Café based on your current screen size and resolution.
Figure 2.4 : The CafÈ desktop.
The first thing that we are going to discuss is the tabbed workspaces at the top left section of the screen. Right now, you will see that you are in the Editing workspace. Click the Browsing tab and watch as the desktop rearranges itself. The Browsing workspace (see Figure 2.5) opens the class viewers that are included in Café-this will be talked about later in the book-allowing you to browse your program from an object standpoint. The Debugging workspace and the Output workspace also are designed to invoke tools specifically related to the workspace title.
Figure 2.5 : The Browsing environment in the CafÈ desktop.
When Symantec designed Café, the company created what it thought was a good development environment and then added other tools that you can use to customize the environment to your own preferences and needs. Rather than attempting to detail the functionality of each of these workspaces at this point, when we have yet to develop anything in Café, we will first spend time customizing the front end.
On the menu bar, click Environment and highlight the Workspace item to expand that sub-menu. You should see Figure 2.6. There are various tools here for the customization of workspace environments.
Figure 2.6 : The Environment menu expanded.
One option that shows the advanced versatility of Symantec Café is the ability to create your own workspaces. Start by clicking New in the Workspace sub-menu shown in Figure 2.6. A dialog box should open up asking you to specify a workspace name. At this point, enter test as the name (see Figure 2.7). Look at the tabbed workspaces and you will see that you have designed your own workspace. The test workspace is not very functional, but the practicality of customizing your own workspace will have many benefits as you continue to develop with this environment.
Figure 2.7 : Tabbed workspace test.
| Note |
When deleting workspaces, be careful that you do not delete any of the original ones (Editing, Browsing, Debugging, and Output). They will be referred to later on in this book. |
Delete the test workspace by using the sub-menu command Delete from the Workspace menu, making sure that when you execute Delete, the test workspace is open (in other words, highlighted).
Another set of options when dealing with Café is the Environment Settings option (see Figure 2.8). This gives you the ability to choose whether to save your workspace every time you exit and also whether to load a project automatically every time you start. This little tool helps to keep you in control of how you want to leave Café and what you want Café to look like when you return.
Figure 2.8 : Environment settings window.
The Views palette toolbar can probably be considered the control center of Symantec Café. It is located to the right of the workspace tabs (see Figure 2.9). Not only is it an array of buttons that can be activated by double-clicking them, it is also a drag and drop icon bar that you can use to edit and debug Java programs. For example, drag the source icon (the first icon on the left in the second toolbar) from the Views palette over to the center of the screen and let go of it. You will see a new source file created exactly where you dropped the icon with your mouse (see Figure 2.10).
Figure 2.9 : The Views palette.
Figure 2.10 : A new Source text editor window.
With the Views palette and the tabbed workspaces, you have just about everything at your fingertips. Looking at Figure 2.6 you also will see the menu item Editing/Browsing Settings under the Environment menu option. Clicking this item will open a tabbed window of options for choosing between various settings (see Figure 2.11). One of the basic options that is interesting is the Backup tab. This tab gives you the ability to toggle the Autosave feature that causes Symantec Café automatically to save your work based on a set number of changes it detects or a set interval of time. Also, it comes with the ability to create a complete backup every time you save and place it in a special location for safekeeping. This option is something that is not available with the Java Development Kit and can become a useful tool.
Figure 2.11 : The Backup options.
Another option that we are going to talk about is the Tools option on the menu bar and the Settings menu item (see Figure 2.12). What this enables you to do is create your own menu items that can be added to the Tools menu. For example, the Internet browser item shown in Figure 2.12 was automatically generated by Symantec Café when it was initially installed. It has linked the Netscape browser installed on the system as the default browser.
Figure 2.12 : Tool Settings windows.
This customizable tool gives you the ability to add outside and third-party tools to Symantec Café. In our example, go ahead and add a program that everyone running in a Windows environment should have: Notepad. Click the Add button (as seen in Figure 2.12). A standard Open dialog box will appear that enables you to go to your Windows directory and locate the Notepad.exe executable. Once you have added the item, it should look something like Figure 2.13.
Figure 2.13 : Tool Settings with Notepad added.
Click OK and the item Notepad will be added to your Tools menu. Go ahead and click it and you will see that it will invoke Notepad. This flexibility provides the capability of customizing Symantec Café to your needs.
We spent Day 1 discussing the high-level information about Java and Café, and you have spent the first part of today getting used to the Symantec Café environment and learning how to customize it. Your final task for today is to create your first runnable Java program with Café.
To better understand the design of Symantec Café, it is important to understand how programs are developed. We'll describe a typical development cycle in just about any programming language, and then illustrate this cycle by developing a simple Java applet.
The development process is going to be a simple one. The more professional and larger the audience of your software, the more complicated this cycle will become. Right now, we will assume that everyone reading this is new to programming (which is probably true regarding Java programming) and design a simple flowchart to show how software is developed and why Symantec Café was designed the way it was. The steps to take are as follows:
Figure 2.14 : The development cycle.
The first step is to create a new project for your first program. Symantec Café uses projects to organize your Java programs. You learn about and work with projects many times throughout the rest of this book. Right now, however, let's begin by learning how to create a project. Creating a new project brings us to one of the most powerful features of Symantec Café: its Express agents. The Express agent that we are going to deal with, called ProjectExpress, enables you to quickly create a new project using point-and-click to select source files and create new source files to start your project.
An Express agent is a wizard-like tool that let you rapidly generate new projects.
| Note |
Symantec has two Express agents that come with Café. The first, ProjectExpress, allows you to start a new project with a few mouse clicks. The other, called appexpress, gets you started with the creation of a new Java program (something that will be described later). |
Now that you know what the ProjectExpress Wizard is, you need to know how to use it. One of the powerful features of Symantec Café is that Express agents are streamlined into the actual environment. Every time a new project is created, it automatically will invoke the ProjectExpress agent. Do that right now: Click the Project menu bar and the New menu item. Figure 2.15 shows the initial screen for ProjectExpress. In the list box at the top left, you can see that ProjectExpress has four screens. First, give your project the name MyProject (see Figure 2.16), making sure that it is located in the ..\Cafe\Projects subdirectory, and then click the Next> button. Now you can choose between various options for the project, and in this case you need to change the Project Settings to Release. Here you will see that you can choose whether the project will be an applet or an application. Change it to an applet.
Figure 2.15 : 1. Name project.
Figure 2.16 : ProjectExpress filled in.
There also are other options at the bottom of the screen that relate to parsing. We will not discuss this until Day 7, so don't worry about the options right now. At this point you should see something like Figure 2.17.
Figure 2.17 : 2. Set project type.
You should not need to make any changes in this step, so go ahead and move onward by clicking the Next> button. You then will be able to add other source code files to your current project. This is useful when you have some standard source files that you want to add to your projects (see Figure 2.18). At this point, we do not have anything that needs to be added to this project, so click the Next> button to move to the final step.
Figure 2.18 : 3. Add files to project.
The final step is to specify the initial settings for this project (see Figure 2.19). You can specify class paths and browser exclude directories specific to this directory. Typically, you will not need to do anything with this step.
Figure 2.19 : 4. Initial Settings.
The last step is to click the Finish button. This closes the ProjectExpress agent and lets you start working on your newly created project.
In the main Café window, take a look at the Project window
and you will see that the folder MyProject.PRJ
shows up there. Essentially, when you created a new project, you
created a file with that name. Symantec Café organizes
its Java applications into projects. Now that you have successfully
created a project using ProjectExpress, you will use this tool
many times in the rest of this book. However, instead of going
through all of the steps one by one, the changes you need to make
in ProjectExpress will be summarized in a table format. For example,
the project that you just created looks like Table 2.1 in tabular
form.
| Step | Actions needed |
| 1. Name project | Project name: MyProject.prj Directory: \Cafe\Projects |
| 2. Set project type | Check option Release |
| 3. Add files to project | No changes |
| 4. Initial Settings | No changes |
The next step is to actually write the code for this Java applet. The code will be written in the Source window text editor. In the main Café screen, it is the large window on the left under the tabbed workspaces that has a title of Untitled. It is here that code for your application and HTML pages can be written. First, you will write the code for the application and save it by entering the code from Listing 2.1 into that window (see Figure 2.20). When that is completed, go to the File menu in that window and save the code in the directory ..\Cafe\Projects. Make sure that you save this applet as HelloWorldApplet.java.
Figure 2.20 : Code for HelloWorldApplet.java in Listing 2.1.
Listing 2.1. The Hello World applet.
1: import java.awt.Graphics;
2:
3: public class HelloWorldApplet extends java.applet.Applet {
4:
5: public void paint(Graphics g) {
6: g.drawString("Hello world!", 5, 25);
7: }
8:}
| Warning |
The numbers before each line are part of the listing and not part of the program; they're there so I can refer to specific line numbers when explaining what's going on in the program. Do not include them in your own file. |
Before moving forward, there are a few things that should be noted about the Source window text editor. Note that this is definitely an upgrade from trying to author code in a proprietary text editor. The Symantec Café editor displays keywords in a special color and comments in another color. This helps you to recognize unbalanced comments and misspelled keywords, making development much easier and resulting in less potential for bugs in the code. However, that is only one of the reasons to use the Source window text editor over a generic text editor. As you will see on Day 14, Symantec is true to its word when it calls Café an Integrated Development Environment. When you attempt to compile your Java programs and encounter errors, Symantec Café will have a point-and-click link to the actual line of code that the compiler tripped on. This makes it easy to pinpoint exactly where an error lies in your code.
| Technical Note |
At this point, a detailed description of what this applet actually is doing would be premature. However, the following are a few things to note about applets:
|
Let's briefly review what we have accomplished. We have created a new project called MyProject and have created a Java source code file called HelloWorldApplet.java. The next step is to make our source code file part of the project. You can do that by going to the File menu and clicking Add to Project. At this point it has been added to the project MyProject. How do we know for sure? Take another look at the Project window (see Figure 2.21).
Figure 2.21 : Project Window containing MyProject.
| Note |
If your project window is not open, you can open it by clicking on the window, expanding the Goto View, and clicking on the Project item. Or you can use the shortcut keys Ctrl-Shift-P. |
Because you are creating a Java applet, you will need an HTML file to view it from. HTML pages also can be written in the Symantec Café Source window text editor and added to projects.
Click New on the File menu and another Source window text editor will appear. Key in the code from Listing 2.2 and save it as Hello.htmL.
Listing 2.2. The HTML with the applet in it.
1: <HTML>
2 : <HEAD>
3 : <TITLE>Hello to Everyone!</TITLE>
4 : </HEAD><BODY>
5 : <APPLET CODE="HelloWorldApplet.class" WIDTH=150 HEIGHT=25></APPLET>
6 : </BODY>
7: </HTML>
Listing 2.2 should look something like Figure 2.22. It is similar to the HTML page on Day 1. Now our final step in the authoring section of this program is to add this HTML page to our project by clicking File and Add to Project.
Figure 2.22 : Code for Hello.htmL in Listing 2.2.
You now successfully have authored your first Java applet and a simple HTML page to test it in. The Project window now should look something like Figure 2.23.
Figure 2.23 : Updated Project window containing MyProject.
| Note |
One of the things to note in Figure 2.23 is the red check through the icon next to Hello.htmL. This means that that file has been designated as the main file when this project is executed. You can specify a designation by right-clicking the file, and if the specified file is appropriate, it will have a command Mark as Main that you can use to make it the main file. |
The next step is to compile your new project inside Symantec Café. One of the most powerful features of Symantec Café is its version of the Java compiler. The compiler is a native one that is much faster than the javac.exe compiler that comes with the Java Development Kit. You will have a chance to work with it many times throughout the rest of this book.
Click Project on the top window and click Rebuild All. This command will recompile everything in your project. Another command, Build, should be used if you make a minor change to an already compiled Java project. The reason for having both of these tools is speed. If you already have a compiled Java project and just make some minor changes, it will take much less time for you to click Build instead of Rebuild All.
It is now time to introduce another window: the Output window. This is where you can tell if your project compiled with any errors or not. Figure 2.24 shows the output window with the compilation status of the project MyProject.
Figure 2.24 : Output after compiling MyProject.
As mentioned yesterday, Symantec Café and the Java Development Kit both come with the appletviewer to view Java applets. Today we will have a chance to actually use it. The appletviewer's primary function is to look for and use the <APPLET> tag in HTML pages passed to it. This tool gives you the ability to view your applets from HTML pages.
In Symantec Café you can invoke the appletviewer by clicking the Project menu bar at the top window and clicking Execute Program. Essentially, Symantec Café automatically will minimize itself and load the appletviewer, and when you exit appletviewer Café automatically will restore itself (see Figure 2.25).
Figure 2.25 : Using appletviewer to view MyProject.
| Note |
| With this method (i.e. the appletviewer), you can view all of your applet-based projects. |
Earlier today, you worked with the menu bar Tools. If you have an Internet browser installed on your system, during the installation of Symantec Café it automatically was added to your Tools menu. You can use this to view your project with a real Internet browser. Here, you can see that the output is similar to what was shown in yesterday's example about the HTML side of adding Java applets to a Web page.
| Note |
If the default browser installed on your system is not Java compliant, you will not be able to view your Java applets. Also, if you do not have an Internet browser installed, you will not have this option on the Tools menu. |
Click the Tools menu and then click Internet Browser. In our example the default browser is Netscape, so the result of pushing the button is shown in Figure 2.26.
Figure 2.26 : Viewing MyProject on an Internet browser.
Today you covered a lot of groundbreaking material in working with Café. The design of Café was discussed along with how to customize and control it to better suit your needs. You then were introduced to one of Symantec Café's agents, the ProjectExpress agent, to automate the creation of new Java applications and applets. Finally, the day ended with some hands-on experience creating your first Java applet and testing it with the appletviewer and a Java-enabled browser. Although we only have introduced all of the functionality that comes with Café, this will help you to create real-world examples for the next few days. Notwithstanding, the following days will be focused more on Java; however, you still will have a chance to work with Symantec Café to try out the examples.
| In Symantec Café, I am able to create a project using the Express agent (that is, wizard) to create a new project. But what if I want to change a setting later on? | |
| This can be done by going to the Project menu and clicking the Settings command, which opens a window with several tabs. Through these tabs you can make changes to the currently opened project. | |
| Must I use Symantec Café's native compiler? | |
| No. Go to the Project Settings window by clicking on the menu Project and the Settings command. Then go to the Build tab, where you can choose if you want to use Symantec's compiler or the Sun javac compiler that comes with the Java Development Kit. It should be noted, however, that the native compiler is much faster and was tested on all of the examples. | |
| Will Symantec Café be available for platforms other than Windows? | |
| Yes. Currently Symantec is brewing a version of Symantec Café for the Macintosh. Right now a patch is available for Power Macintosh users who have Symantec C++ for Macintosh. It is
called Caffeine, and gives Symantec C++ users in the Macintosh environment the ability to write Java programs in Symantec C++. For more information, check out the following Web site:
http://cafe.symantec.com |