The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
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. 不要害怕!使用Java环境中提供的网络功能非常容易。In fact, you may be using the network already without even realizing it!事实上,你可能已经在使用网络了,甚至都没有意识到!
If you have access to a Java-enabled browser, you have undoubtedly already executed many applets. 如果您能够访问支持Java的浏览器,那么毫无疑问您已经执行了许多小程序。The applets you've run are referenced by a special tag in an HTML file the 您运行的小程序由HTML文件中的一个特殊标记引用#151;<APPLET>
tag. <APPLET>
标签。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 the 但是,小程序的位置是在<APPLET>
tag. <applet>
标记中编码的。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. 这是从Java开发环境访问Internet的最高级别。Someone else has taken the time to write a browser that does all of the grunt 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!" Application“Hello World!”应用程序 shows you how to write your first applet and run it.演示如何编写第一个小程序并运行它。
The Java Applets trail describes how to write Java applets from A to Z.Java小程序教程描述了如何从A到Z编写Java小程序。
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. 如果您已经开始编写自己的Java小程序和应用程序,那么您可能在javanet包中遇到了一个名为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. 您的小程序和应用程序可以使用URL来引用甚至连接到网络上的资源。For example, to load an image from the network, your Java program must first create a URL that contains the address to the image.例如,要从网络加载图像,Java程序必须首先创建一个包含图像地址的URL。
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 function in the Java development environment that does the grunt work of connecting to the network and retrieving the resource.这是你与互联网互动的第二高层次#151;您的Java程序获得它想要的东西的地址,为它创建一个URL,然后使用Java开发环境中的一些现有功能,完成连接到网络和检索资源的繁重工作。
For more information:有关更多信息:
How to Use Icons如何使用图标 shows you how to load an image into your Java program (whether applets or applications) when you have its URL. 演示如何在有图像的URL时将其加载到Java程序(小程序或应用程序)中。Before you can load the image you must create a URL object with the address of the resource in it.在加载图像之前,必须创建一个包含资源地址的URL对象。
Working with URLs使用URL, 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.,本教程的下一课提供了有关URL的完整讨论,包括程序如何连接到URL,以及如何读取和写入该连接。