|
To access the contents, click the chapter and section titles.
Sams Teach Yourself Visual J++ 6 in 21 Days
Making Applets LiveAfter youve created an applet, the chances are pretty good that youll want to make it available to the entire Web population. To do this, you must upload the various files that make up the applet to a Web site and test them, to make sure that nothing breaks in the process. To upload applets to a Web site, you must have the authority and the tools (such as an ftp tool) to do so. If the site you want to add the applet to is maintained by someone other than yourself, youll have to obtain permission and perhaps even get the access passwords if you plan to upload the materials yourself. If you dont already have such authority, you can give the applet and the various files it uses to someone who will eventually perform the upload. Obtaining WS_FTPMy preference in tools for doing the file uploads is WS_FTP. Its a great FTP tool that you can download from a Web site. The version thats downloadable is a trial version. If you decide to continue using it, youre expected to buy the full version. To get a copy of WS_FTP, go to the Ipswitch Web site at http://www.abraxis.com/ipswitch/Default.htm. Besides getting the trial version, youll be able to check out Ipswitchs entire line of products. For the remainder of this chapter, the FTP program well use is WS_FTP. Before going any further, you might want to download the program and install it on your system. Creating the Web Server Directory LayoutIf this is the first time Java is being used at a site, it might be a good idea to create a directory structure that will contain the Java classes and other associated files such as audio and graphics files. This is pretty straightforward and will be similar to how the directory structure is set up on your local drive. Make sure that you know in which directory the initial HTML file will be located. Many services require an index HTML file in a directory, and Web browsers that hit the site will automatically load this particular file. If your service has this requirement, you will probably want to place your Java files in this directory. Connecting to the ServerIf you have permission to upload files to a site on the Web, youre ready to get started. After WS_FTP32 is installed, run it. The Session Properties dialog box, shown in Figure 3.3, will appear on top of the main program window.
In this dialog box, youll enter information about the destination server, including its name (or IP address), your login name, and your password. If you have the Save Password and Auto Save Config check boxes selected, the information will be saved and you can log in by simply selecting the server from a list. Fill in the Profile Name, Host Name, User ID, and Password fields. Its a good idea to make the Profile Name and Host Name the same to avoid ambiguity. With the information correctly entered, click the OK button and the program will try to log on to the server. The left list box of WS_FTPs main window contains a listing of the current directory, even when youre not logged on to a server. When logged in, youll see a directory listing in the list box on the right half of the screen, as shown in Figure 3.4. This shows only the names of the files and directories, not file and directory details. To get a listing of full file and directory information, click DirInfo in the right column of buttons.
Youll have to know how to find your directory on the server. Many ISPs have a directory structure that will make it hard to find your directory. Make sure that you have the documentation for your account. Although it might be cryptic (as is usually the case), itll be your best bet of finding the directory. Other ISPs are more understanding and drop you right into your directory after you log on. These are the steps for connecting to a server:
Uploading the AppletAfter youre connected, you can upload the files. Ill use a HelloWorld applet as an example. You must upload HelloWorld.class and HelloWorld.html. Not all three of these files (the HelloWorld.html, HelloWorld.class, and HelloWorld.java files) are necessary to run the Java programonly HelloWorld.class is required. You can upload HelloWorld.java if you want to offer the source code for download. Our example here will assume that youre uploading the .java source code so that users can download it. The HelloWorld.html file is the HTML file that J++ created with some additional lines so that users can download the source code. Later in the chapter, well talk about incorporating this code into another HTML file, but for simplicity youll use it as it was created and have your main HTML file upload HelloWorld.html. Begin by navigating the left list box so that it shows all three HelloWorld files. Highlight them as shown in Figure 3.5 and then click the -> button.
The files will be uploaded to the server. Because the files are short and most modem connections are pretty fast, you wont see much more than a blink as the upload progress box appears during the upload. For longer files, the upload progress box will stay visible long enough for you to see it.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |