Table of Contents |
The word networking strikes fear in the hearts of many programmers. Fear not! Using the networking capabilities provided in the Java environment is quite easy. In fact, you may have been using the network already without even realizing it!If you've been working on the other trails in this tutorial, you've certainly loaded an applet over the Internet by now, and you've likely loaded images into your applets or applications. All of this is using the network and you already know how to do it. This page highlights the networking features that are covered in other trails and lessons of this tutorial--features that you might already be familiar with--and provides links to the pages that discuss those features.
Loading Applets from the Network
If you have access to a Java-enabled browser, you have undoubtedbly already executed many applets. The applets you've run are referenced by a special tag in an HTML file--theapplet
tag. The applets can be located anywhere, whether on your local machine or somewhere out on the Internet. The location of the applet is completely invisible to you, the user. However, the location of the applet is encoded within theapplet
tag. The browser decodes this information, locates the applet, and runs it. If the applet is on some machine other than your own, the browser must download the applet before it can be run.This is the highest level of access that you have to the Internet from the Java development environment. Someone else has taken the time to write a browser that does all of the grunge work of connecting to the network and getting data from it, thereby enabling you to run applets from anywhere in the world.
For more information:
The "Hello World" Applet is a brief lesson that shows you how to write your first applet and run it.The Writing Applets trail describes how to write Java applets from A to Z.
Loading Images from URLs
If you've ventured into writing your own Java applets and applications, you may have run into a class in the java.net package called URL. This class represents a Uniform Resource Locator and is the address of some resource on the network. Your applets and applications can use a URL to reference and even connect to resources out on the network. For example, to load images from the network, your Java program must first create a URL that contains the address to the image.This is the next highest level of interaction you can have with the Internet--your Java program gets an address of something it wants, creates a URL for it, and then uses some existing functionality in the Java development environment that does the grunge work of connecting to the network and retrieving the resource.
For more information:
Loading Images shows you how to load a image into your Java program (whether applets or applications) when you have its URL. Before you can load the image you must create a URL object with the address of the resource in it.Working with URLs , the next lesson in this trail, provides a complete discussion about URLs including how your programs can connect to them and read from and write to that connection.
Table of Contents |