1、此文档是毕业设计外文翻译成品(含英文原文+中文翻译),无需调整复杂的格 式!下载之后直接可用,方便快捷!本文价格不贵,也就几十块钱! 一辈子也就 一次的事!文献出处:David ParsonsFoundational Java, 2019,pp 503-527 (如觉得年份太老,可改为近2年,毕竟很多毕业生都这样做)英文3584单词,19270字符(字符就是印刷符),中文5622汉字。(如果字数多 了,可自行删减,大多数学校都是要求选取外文的一部分内容进行翻译的。)Java Web Start and AppletsIn its early days, Java came to promine
2、nce because of Java applets, running in web browsers. Applets have had something of a checkered history since then, and most Java web technologies belong in the enterprise edition rather than the standard edition of Java. However, applets are still widely used, and can be a useful component of rich
3、Internet applications. Also associated with the web, but less directly, is Java Web Start, which allows desktop applications to be deployed over the web. In this chapter, we will begin by looking at Java Web Start and then look at applets, which can now use the same deployment mechanism as Java Web
4、Start, making it very easy to switch between the two modes of deployment. Since both Java Web Start and applets require us to create web pages with appropriate links to Java applications or applets, we will begin with brief overviews of web browsers, URLs, and HTML.20.1Web Browsers, URLs, and HTML P
5、agesWeb browser software (e.g., Explorer, Firefbx, Safari, Chrome, etc.) is designed to retrieve information from remote sites on the World Wide Web (WWW) using Uniform Resource Locators (URLs). Much of the information is made available in the form of HTML (HyperText Markup Language) web pages.20.1.
6、1URLsA URL is basically the Internet address of a resource on a particular server, andtypically is written in three parts: the protocol, the server address, and the name of the resource (including any path information).20.1.1.1 The HTTP ProtocolThe protocol prefix for web pages is “http:/”. This sta
7、nds for “hypertext transfer protocol” and most URLs start this way. Indeed this part is often omitted, because it is usually the browsers default protocol (though there are other web protocols that you may be familiar with such as FTP, the File Transfer Protocol).20.1.1.2The Server AddressThe server
8、 address usually begins with “www” (World Wide Web), followed by the name of the site and its “domain,” which defines its category and may include its country code. Each of these is separated by a period (full stop). Take, for example, the following URL:“introjava” is the name of the server site and
9、 “com” means a company. Common alternatives to “com” are “edu” for academic institutions and “org” for organizations. Many URLs are within a country domain, such as “.co.uk” or “ac.nz”. If you are running a test server on your local machine, the domain name becomes “localhost.”20.1.1.3The Path and R
10、esource NameThe final part of a URL can include the location (directory) and name of the particular file at the site. For example,http:/www.apache.org/foundation/getinvolved.htmlThis looks for the file “getinvolved.html” in the “foundation” directory. The file name will generally end in “html” (or s
11、ometimes just “htm”) because it will usually be a file written in HTML (see below). If no file name is specified, “index.html” is often the servers default file name that it will send back to the browser. If no index file ispresent, then a directory listing may be displayed instead, or an error page
12、, depending on the servers configuration.20.1.2 HTML (HyperText Markup Language)Web browsers display screens of information written using HTML (HyperText Markup Language). The browser takes the basic information stored in the HTML file and formats it appropriately using tags embedded into the text o
13、f the file. All HTML files begin with an tag and end with . Most HTML tags are terminated like this, using a forward slash followed by the tag name. This is a very simple HTML file, showing additional tags for the page header (, which can include a title ), the main body of the text (), and some tex
14、t. Header tags (such as ) can be used to format the size of text. The tag is used to specify paragraphs. The “DOCTYPE” at the top the file specifies the version of HTML that is being used. This example uses HTML 5 (different DOCTYPES have different expectations about how the document should be struc
15、tured).Fig. 20.1 A simple HTML page loaded into a browserFigure 20.1 shows what this page looks like when loaded into a browser as a local file. Simple files can easily be written by hand, but for more complex pages it is better to use one of the many available HTML editing tools. Some simple HTML p
16、ages will be needed to launch the applications and applets described in this chapter. A simple HTML page This is a headingHere is the text of my HTML page20.2Java Web StartJava Web Start is a generic Rich Internet Application (RIA) launch mechanism that can be used to deploy both desktop application
17、s and applets. It provides a way to easily deploy applications via the web, and provides an alternative to some other types of web deployment, such as some server side web applications, though it primarily eases the deployment of desktop applications. A Java Web Start application can be self-contain
18、ed, because it can automatically download and install a JRE. Programmers can specify which JRE version a given program needs in order to execute and ensure that it is available for the application to run. Although it is a web-based deployment mechanism, no Internet connection is required to execute
19、the applications once they have been downloaded.The core components of a Java Web Start deployment are: the application to be deployed, a Java Network Launch Protocol (JNLP) file, and a web (HTML) page to host the application launcher. The Java application needs to be archived in a JAR file with an
20、identifiable “main” class that serves as the program entry point. As we saw in Chap. 14, a JAR provides a single unit of deployment, and can specify a main class in its manifest. Having the “main” class identified in the manifest is not essential for Java Web Start since we can also specify the main
21、 class in the JNLP file, but it is useful not to rely entirely on the JNLP file to specify a main class.The JNLP file is an XML file that describes how the application should be launched. It contains deployment-related information such as the name of the JAR file, the main class in the JAR, and the
22、minimum version of Java required to run the application. The web page can either contain a simple hyperlink to the JNLP file or it can use a JavaScript button to launch the application. Normally, we would also need to set up aweb application so that the files can be downloaded over the web from a se
23、rver. However, for testing purposes it is possible to deploy a Java Web Start application using a local HTML file, which we will do for the first example, which deploys the Distance Viewer application from Chap. 18.20.2.1 Creating a JAR in EclipseThe first step is to create a JAR file containing the
24、 required classes. This could of course be built using an Ant script, which we will do later in this chapter, but we will describe the first step in this example using the Eclipse export facility. Figure 20.2 shows the key steps in the dialogs that export files from Eclipse. The first step is to sel
25、ect export from the file menu, which will open the Export dialog shown in Fig. 20.1. In this dialog, within the Java folder you can select JAR File as the type of export. Clicking the Next button takes you to the “JAR Export dialog. It is essential here to choose all of the files that need to be in
26、the archive. For the DistanceViewer application, you need to export not only the DistanceViewer class itself (the view), but the Flight Distances class as well (the model). The lower part of the dialog lets you select the export folder and the name of the JAR file. Clicking Next takes you to the fin
27、al stage of the dialog where you can select one of the classes in the JAR as the class used as the application entry point. Clicking Finish creates the JAR file.20.2.2Java Network Launch Protocol (JNLP)The Java Network Launch Protocol (JNLP) enables a desktop application to be launched from resource
28、s hosted on a web server. Java Web Start requires a JNLP file that configures the various aspects of the protocol.Fig. 20.2 Exporting a jar tile from EclipseThis can be created as a text file in Eclipse, with a “jnlp” extension. It needs to be explicitly opened in a text editor or Eclipse may attemp
29、t to run it directly (right-click on the file and choose “open with”, then select “text editor”). The following example contains the basic information required in a JNLP file. The “information” element requires “title” and “vendor” information. The “resources” element specifies the minimum version o
30、f Java required to run the application (with the URL of the automatic download site for the Java runtime), and the name of the JAR file. Finally the “applicationdesc” element specifies the name of the main class to be run from the JAR. This particular JNLP file has been written using the required el
31、ements from Java Web Start version 1; hence, the “spec” attribute is set to “1.0+” (this is actually the default).Note that the “codebase” and “href attributes are empty in this example - they are not required when testing local files.Flight Distances Viewer Foundational Javaj2se version=”1.6+href- Hyperlinks do not particul