java外文资料翻译
Java编程语言外文翻译、英汉互译、中英对照
文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。
外文翻译原文及译文学院计算机学院专业计算机科学与技术班级学号姓名指导教师负责教师Java(programming language)Java is a general-purpose, concurrent, class-based, object-oriented computer program- -ming language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to byte code (class file) that can run on any Java virtual machine(JVM) regardless of computer architecture. Java is, as of 2012, one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users. Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1991 and first released in 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Classpath.Java is a set of several computer software products and specifications from Sun Microsystems (which has since merged with Oracle Corporation), that together provide a system for developing application software and deploying it in across-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones on the low end, to enterprise servers and supercomputers on the high end. While less common, Java appletsare sometimes used to provide improved and secure functions while browsing the World Wide Web on desktop computers.Writing in the Java programming language is the primary way to produce code that will be deployed as Java bytecode. There are, however, byte code compilers available forother languages such as Ada, JavaScript, Python, and Ruby. Several new languages have been designed to run natively on the Java Virtual Machine (JVM), such as Scala, Clojure and Groovy.Java syntax borrows heavily from C and C++, but object-oriented features are modeled after Smalltalk and Objective-C. Java eliminates certain low-level constructs such as pointers and has a very simple memory model where every object is allocated on the heap and all variables of object types are references. Memory management is handled through integrated automatic garbage collection performed by the JVM.An edition of the Java platform is the name for a bundle of related programs from Sun that allow for developing and running programs written in the Java programming language. The platform is not specific to any one processor or operating system, but rather an execution engine (called a virtual machine) and a compiler with a set of libraries that are implemented for various hardware and operating systems so that Java programs can run identically on all of them. The Java platform consists of several programs, each of which provides a portion of its overall capabilities. For example, the Java compiler, which converts Java source code into Java byte code (an intermediate language for the JVM), is provided as part of the Java Development Kit (JDK). The Java Runtime Environment(JRE), complementing the JVM with a just-in-time (JIT) compiler, converts intermediate byte code into native machine code on the fly. An extensive set of libraries are also part of the Java platform.The essential components in the platform are the Java language compiler, the libraries, and the runtime environment in which Java intermediate byte code "executes" according to the rules laid out in the virtual machine specification.In most modern operating systems (OSs), a large body of reusable code is provided to simplify the programmer's job. This code is typically provided as a set of dynamically loadable libraries that applications can call at runtime. Because the Java platform is not dependent on any specific operating system, applications cannot rely on any of the pre-existing OS libraries. Instead, the Java platform provides a comprehensive set of its own standard class libraries containing much of the same reusable functions commonly found in modern operating systems. Most of the system library is also written in Java. For instance, Swing library paints the user interface and handles the events itself, eliminatingmany subtle differences between how different platforms handle even similar components.The Java class libraries serve three purposes within the Java platform. First, like other standard code libraries, the Java libraries provide the programmer a well-known set of functions to perform common tasks, such as maintaining lists of items or performing complex string parsing. Second, the class libraries provide an abstract interface to tasks that would normally depend heavily on the hardware and operating system. Tasks such as network access and file access are often heavily intertwined with the distinctive implementations of each platform. The and java.io libraries implement an abstraction layer in native OS code, then provide a standard interface for the Java applications to perform those tasks. Finally, when some underlying platform does not support all of the features a Java application expects, the class libraries work to gracefully handle the absent components, either by emulation to provide a substitute, or at least by providing a consistent way to check for the presence of a specific feature.The success of Java and its write once, run anywhere concept has led to other similar efforts, notably the .NET Framework, appearing since 2002, which incorporates many of the successful aspects of Java. .NET in its complete form (Microsoft's implementation) is currently only fully available on Windows platforms, whereas Java is fully available on many platforms. .NET was built from the ground-up to support multiple programming languages, while the Java platform was initially built to support only the Java language, although many other languages have been made for JVM since..NET includes a Java-like language called Visual J# (formerly named J++) that is incompatible with the Java specification, and the associated class library mostly dates to the old JDK 1.1 version of the language. For these reasons, it is more a transitional language to switch from Java to the .NET platform, than a first class .NET language. Visual J# was discontinued with the release of Microsoft Visual Studio 2008. The existing version shipping with Visual Studio 2005will be supported until 2015 as per the product life-cycle strategy.In June and July 1994, after three days of brainstorming with John Gage, the Director of Science for Sun, Gosling, Joy, Naughton, Wayne Rosing, and Eric Schmidt, the team re-targeted the platform for the World Wide Web. They felt that with the advent of graphical web browsers like Mosaic, the Internet was on its way to evolving into the samehighly interactive medium that they had envisioned for cable TV. As a prototype, Naughton wrote a small browser, Web Runner (named after the movie Blade Runner), later renamed Hot Java.That year, the language was renamed Java after a trademark search revealed that Oak was used by Oak Technology. Although Java 1.0a was available for download in 1994, the first public release of Java was 1.0a2 with the Hot Java browser on May 23, 1995, announced by Gage at the Sun World conference. His announcement was accompanied by a surprise announcement by Marc Andreessen, Executive Vice President of Netscape Communications Corporation, that Netscape browsers would be including Java support. On January 9, 1996, the Java Soft group was formed by Sun Microsystems to develop the technology.Java编程语言Java是一种通用的,并发的,基于类的并且是面向对象的计算机编程语言,它是为实现尽可能地减少执行的依赖关系而特别设计的。
JAVA外文资料翻译
doc文ห้องสมุดไป่ตู้可能在WAP端浏览体验不佳。建议您优先选择TXT,或下载源文件到本机查看。
外文文献原文及翻译 作 者:辛明 生物医学工程学院影像工程专业 生物医学工程学院信息技术系 指导老师:杨谊
Parsing Java Abstraction of the Difference Between Classes and Interfaces In Java language, abstract scale-up and with support class abstraction definition of two mechanisms. Because of these two kinds of mechanism of existence, just gives Java powerful object-oriented skills. Abstract scale-up and with between class abstraction definition for support has great similarities, even interchangeable, so many developers into line nonabstract class definition for abstract scale-up and it is becoming more casual with choice. In fact, both between still has the very big difference, for their choice even reflected in problem domain essence of understanding, to design the intentions of the understand correctly and reasonable. This paper will for the difference analysis, trying to give a developer with a choice between them are based. Understand class abstraction Abstract class and interface in Java language is used for abstract classes (in this article nonabstract class not from abstract scale-up translation, it represents an abstract body, and abstract scale-up for Java language used to define class abstraction in one way, please readers distinguish) defined, then what are the abstract classes, use abstract classes for us any good? In object-oriented concept, we know all objects is through class to describe, but in turn not such. Not all classes are used to describe object, if a class does not contain enough information to portray a concrete object, this class is abstract classes. Abstract classes are often used to characterization of problem field in our analysis, design that the abstract concepts, is to the series will look different, but essentially the same exact conception of abstraction. For example: if we carry out a graphical editing software development, will find problem domain exists round, triangle so some specific concept, they are different, but they all belong to shape such a concept, shape this concept in problem domain is not exist, it is an abstract concept. Precisely because the abstract concepts in problem field no corresponding specific concept, so to characterization abstract concepts nonabstract class cannot be instantiated. In an object-oriented field, mainly used for class abstraction types hidden. We can construct a fixed a group of behavior of abstract description, but this group of behavior but can have any a possible concrete implementation. This abstract describe is abstract classes, and this an arbitrary a possible concrete realization is behaved for all possible derived class. Modules can be operating an abstract body. Due to the module dependent on a fixed abstraction body, so it can are not allowed to modify, Meanwhile, through the abstract derived from the body, also can expand the behavior of this module function. Familiar with OCP readers must know, object-oriented design to be able to achieve a core principles OCP (Open - Closed flying), class abstraction is one of the key. From the perspectives of grammar definition abstract class and interface
JAVA外文文献+翻译
Java and the InternetIf Java is, in fact, yet another computer programming language, you may question why it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn’t immediately obvious if you’re coming from a traditional programming perspective. Although Java is very useful for solving traditional stand-alone programming problems, it is also important because it will solve programming problems on the World Wide Web.1.Client-side programmingThe Web’s initial server-browser design provided for interactive content, but the interactivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them. Basic HTML contains simple mechanisms for data gathering: text-entry boxes, check boxes, radio boxes, lists and drop-down lists, as well as a button that can only be programmed to reset the data on the form or “submit” the data on the form back to the server. This submission passes through the Common Gateway Interface (CGI) provided on all Web servers. The text within the submission tells CGI what to do with it. The most common action is to run a program located on the server in a directory that’s typically called “cgi-bin.” (If you watch the address window at the top of your browser when you push a button on a Web page, you can sometimes see “cgi-bin” within all the gobbledygook there.) These programs can be written in most languages. Perl is acommon choice because it is designed for text manipulation and is interpreted, so it can be installed on any server regardless of processor or operating system. Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of response time. The response of a CGI program depends on how much data must be sent, as well as the load on both the server and the Internet. (On top of this, starting a CGI program tends to be slow.) The initial designers of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of applications people developed. For example, any sort of dynamic graphing is nearly impossible to perform with consistency because a GIF file must be created and moved from the server to the client for each version of the graph. And you’ve no doubt had direct experience with something as simple as validating the data on an input form. You press the submit button on a page; the data is shipped back to the server; the server starts a CGI program that discovers an error, formats an HTML page informing you of the error, and then sends the page back to you; you must then back up a page and try again. Not only is this slow, it’s inelegant.The solution is client-side programming. Most machines that run Web browsers are powerful engines capable of doing vast work, and with the original static HTML approach they are sitting there, just idly waiting for the server to dish up the next page. Client-side programming means that the Web browser is harnessed to do whatever work it can, and the result for the user is a much speedier and more interactive experience at your Web site.The problem with discussions of client-side programming is that they aren’t very different from discussions of programming in general. The parameters are almost the same, but the platform is different: a Web browser is like a limited operating system. In the end, you must still program, and this accounts for the dizzying array of problems and solutions produced by client-side programming. The rest of this section provides an overview of the issues and approaches in client-side programming.2.Plug-insOne of the most significant steps forward in client-side programming is the development of the plug-in. This is a way for a programmer to add new functionality to the browser by downloading a piece of code that plugs itself into the appropriate spot in the browser. It tells the browser “from now on you can perform this new activity.” (You ne ed to download the plug-in only once.) Some fast and powerful behavior is added to browsers via plug-ins, but writing a plug-in is not a trivial task, and isn’t something you’d want to do as part of the process of building a particular site. The value of the plug-in for client-side programming is that it allows an expert programmer to develop a new language and add that language to a browser without the permission of the browser manufacturer. Thus, plug-ins provide a “back door” that allows the creation of new client-side programming languages (although not all languages are implemented as plug-ins).3.Scripting languagesPlug-ins resulted in an explosion of scripting languages. With a scripting language you embed the source code for your client-side program directly into the HTML page, and the plug-in that interprets that language is automatically activated while the HTML page is being displayed. Scripting languages tend to be reasonably easy to understand and, because they are simply text that is part of an HTML page, they load very quickly as part of the single server hit required to procure that page. The trade-off is that your code is exposed for everyone to see (and steal). Generally, however, you aren’t doing amazingly sophisticated things with scripting languages so this is not too much of a hardship.This points out that the scripting languages used inside Web browsers are really intended to solve specific types of problems, primarily the creation of richer and more interactive graphical user interfaces (GUIs). However, a scripting language might solve 80 percent of the problems encountered in client-side programming. Your problems might very well fit completely withinthat 80 percent, and since scripting languages can allow easier and faster development, you should probably consider a scripting language before looking at a more involved solution such as Java or ActiveX programming.The most commonly discussed browser scripting languages are JavaScript (which has nothing to do with Java; it’s named that way just to grab some of Java’s marketing momentum), VBScript (which looks like Visual Basic), and Tcl/Tk, which comes from the popular cross-platform GUI-building language. There are others out there, and no doubt more in development.JavaScript is probably the most commonly supported. It comes built into both Netscape Navigator and the Microsoft Internet Explorer (IE). In addition, there are probably more JavaScript books available than there are for the other browser languages, and some tools automatically create pages using JavaScript. However, if you’re already fluent in Visual Basic or Tcl/Tk, you’ll be more productive using those scripting languages rather than learning a new one. (You’ll have your hands full dealing with the Web issues already.)4.JavaIf a scripting language can solve 80 percent of the client-side programming problems, what about the other 20 percent—the “really hard stuff?” The most popular solution today is Java. Not only is it a powerful programming language built to be secure, cross-platform, and international, but Java is being continually extended to provide language features and libraries that elegantly handle problems that are difficult in traditional programming languages, such as multithreading, database access, network programming, and distributed computing. Java allows client-side programming via the applet.An applet is a mini-program that will run only under a Web browser. The applet is downloaded automatically as part of a Web page (just as, for example, a graphic is automatically downloaded). When the applet is activated it executes a program. This is part of its beauty—it provides you with a way to automatically distribute the client software from the server at the time the user needs the client software, and no sooner. The user gets the latest version of the client software without fail and without difficult reinstallation. Because of theway Java is designed, the programmer needs to create only a single program, and that program automatically works with all computers that have browsers with built-in Java interpreters. (This safely includes the vast majority of machines.) Since Java is a full-fledged programming language, you can do as much work as possible on the client before and after making requests of the server. F or example, you won’t need to send a request form across the Internet to discover that you’ve gotten a date or some other parameter wrong, and your client computer can quickly do the work of plotting data instead of waiting for the server to make a plot and ship a graphic image back to you. Not only do you get the immediate win of speed and responsiveness, but the general network traffic and load on servers can be reduced, preventing the entire Internet from slowing down.One advantage a Java applet has ove r a scripted program is that it’s in compiled form, so the source code isn’t available to the client. On the other hand, a Java applet can be decompiled without too much trouble, but hiding your code is often not an important issue. Two other factors can be important. As you will see later in this book, a compiled Java applet can comprise many modules and take multiple server “hits” (accesses) to download. (In Java 1.1 and higher this is minimized by Java archives, called JAR files, that allow all the required modules to be packaged together and compressed for a single download.) A scripted program will just be integrated into the Web page as part of its text (and will generally be smaller and reduce server hits). This could be important to the responsiveness of your Web site. Another factor is the all-important learning curve. Regardless of what you’ve heard, Java is not a trivial language to learn. If you’re a Visual Basic programmer, moving to VBScript will be your fastest solution, and since it will probably solve most typical client/server problems you might be hard pressed to justify learning Java. If you’re experienced with a scripting language you will certainly benefit from looking at JavaScript or VBScript before committing to Java, since they might fit your needs handily and you’ll be more productive sooner.to run its applets withi5.ActiveXTo some degree, the competitor to Java is Microsoft’s ActiveX, although it takes a completely different approach. ActiveX was originally a Windows-only solution, although it is now being developed via an independent consortium to become cross-platform. Effectively, ActiveX says “if your program connects to its environment just so, it can be dropped into a Web page and run under a browser that supports ActiveX.” (I E directly supports ActiveX and Netscape does so using a plug-in.) Thus, ActiveX does not constrain you to a particular language. If, for example, you’re already an experienced Windows programmer using a language such as C++, Visual Basic, or Borland’s Del phi, you can create ActiveX components with almost no changes to your programming knowledge. ActiveX also provides a path for the use of legacy code in your Web pages.6.SecurityAutomatically downloading and running programs across the Internet can sound like a virus-builder’s dream. ActiveX especially brings up the thorny issue of security in client-side programming. If you click on a Web site, you might automatically download any number of things along with the HTML page: GIF files, script code, compiled Java code, and ActiveX components. Some of these are benign; GIF files can’t do any harm, and scripting languages are generally limited in what they can do. Java was also designed to run its applets within a “sandbox” of safety, which prevents it from wri ting to disk or accessing memory outside the sandbox.ActiveX is at the opposite end of the spectrum. Programming with ActiveX is like programming Windows—you can do anything you want. So if you click on a page that downloads an ActiveX component, that component might cause damage to the files on your disk. Of course, programs that you load onto your computer that are not restricted to running inside a Web browser can do the same thing. Viruses downloaded from Bulletin-Board Systems (BBSs) have long been a problem, but the speed of the Internet amplifies the difficulty.The solution seems to be “digital signatures,” whereby code is verified to show who the author is. This is based on the idea that a virus works because its creator can be anonymous, so if you remove the anonymity individuals will be forced to be responsible for their actions. This seems like a good plan because it allows programs to be much more functional, and I suspect it will eliminate malicious mischief. If, however, a program has an unintentional destructive bug it will still cause problems.The Java approach is to prevent these problems from occurring, via the sandbox. The Java interpreter that lives on your local Web browser examines the applet for any untoward instructions as the applet is being loaded. In particular, the applet cannot write files to disk or erase files (one of the mainstays of viruses). Applets are generally considered to be safe, and since this is essential for reliable client/server systems, any bugs in the Java language that allow viruses are rapidly repaired. (It’s worth noting that the browser software actually enforces these security restrictions, and some browsers allow you to select different security levels to provide varying degrees of access to your system.) You might be skeptical of this rather draconian restriction against writing files to your local disk. For example, you may want to build a local database or save data for later use offline. The initial vision seemed to be that eventually everyone would get online to do anything important, but that was soon seen to be impractical (although low-cost “Internet appliances” might someday satisfy the needs of a significant segment of users). The solution is the “signed applet” that uses public-key encryption to verify that an applet does indeed come from where it claims it does. A signed applet can still trash your disk, but the theory is that since you can now hold the applet creator accountable they won’t do vicious things. Java provides a framework for digital signatures so that you will eventually be able to allow an applet to step outside the sandbox if necessary. Digital signatures have missed an important issue, which is the speed that people move around on the Internet. If you download a buggy program and it does something untoward, how long will it be before you discover the damage? It could be days or even weeks. By then, how will you track down the program that’s done it? And what good will it do you at that point?7.Internet vs. intranetThe Web is the most general solution to the client/server problem, so it makes sense that you can use the same technology to solve a subset of the problem, in particular the classic client/server problem within a company. With traditional client/server approaches you have the problem of multiple types of client computers, as well as the difficulty of installing new client software, both of which are handily solved with Web browsers and client-side programming. When Web technology is used for an information network that is restricted to a particular company, it is referred to as an intranet. Intranets provide much greater security than the Internet, since you can physically control access to the servers within your company. In terms of training, it seems that once people und erstand the general concept of a browser it’s much easier for them to deal with differences in the way pages and applets look, so the learning curve for new kinds of systems seems to be reduced.The security problem brings us to one of the divisions that seems to be automatically forming in the world of client-side programming. If your program is running on the Internet, you don’t know what platform it will be working under, and you want to be extra careful that you don’t disseminate buggy code. You need something cross-platform and secure, like a scripting language or Java.If you’re running on an intranet, you might have a different set of constraints. It’s not uncommon that your machines could all be Intel/Windows platforms. On an intranet, you’re respon sible for the quality of your own code and can repair bugs when they’re discovered. In addition, you might already have a body of legacy code that you’ve been using in a more traditional client/server approach, whereby you must physically install client programs every time you do an upgrade. The time wasted in installing upgrades is the most compelling reason to move to browsers, because upgrades are invisible and automatic. If you are involved in such an intranet, the most sensible approach to take is the shortest path that allows you to use your existing code base, rather than trying to recode your programs in a new language.When faced with this bewildering array of solutions to the client-side programming problem, the best plan of attack is a cost-benefit analysis. Consider the constraints of your problem and what would be the shortest path to your solution. Since client-side programming is still programming, it’s always a good idea to take the fastest development approach for your particular situation. This is an aggressive stance to prepare for inevitable encounters with the problems of program development.8.Server-side programmingThis whole discussion has ignored the issue of server-side programming. What happens when you make a request of a server? Most of the time the request is simply “send me this file.” Your browser then interprets the file in some appropriate fashion: as an HTML page, a graphic image, a Java applet, a script program, etc. A more complicated request to a server generally involves a database transaction. A common scenario involves a request for a complex database search, which the server then formats into an HTML page and sends to you as the result. (Of course, if the client has more intelligence via Java or a scripting language, the raw data can be sent and formatted at the client end, which will be faster and less load on the server.) Or you might want to register your name in a database when you join a group or place an order, which will involve changes to that database. These database requests must be processed via some code on the server side, which is generally referred to as server-side programming. Traditionally, server-side programming has been performed using Perl and CGI scripts, but more sophisticated systems have been appearing. These include Java-based Web servers that allow you to perform all your server-side programming in Java by writing what are called servlets. Servlets and their offspring, JSPs, are two of the most compelling reasons that companies who develop Web sites are moving to Java, especially because they eliminate the problems of dealing with differently abled browsers.9. separate arena: applicationsMuch of the brouhaha over Java has been over applets. Java is actually a general-purpose programming language that can solve any type of problem—at least in theory. And as pointed out previously, there might be more effective ways to solve most client/server problems. When you move out of the applet arena (and simultaneously release the restrictions, such as the one against writing to disk) you enter the world of general-purpose applications that run standalone, without a Web browser, just like any ordinary program does. Here, Java’s strength is not only in its portability, but also its programmability. As you’l l see throughout this book, Java has many features that allow you to create robust programs in a shorter period than with previous programming languages. Be aware that this is a mixed blessing. You pay for the improvements through slower execution speed (although there is significant work going on in this area—JDK 1.3, in particular, introduces the so-called “hotspot” performance improvements). Like any language, Java has built-in limitations that might make it inappropriate to solve certain types of programming problems. Java is a rapidly evolving language, however, and as each new release comes out it becomes more and more attractive for solving larger sets of problems.Java和因特网既然Java不过另一种类型的程序设计语言,大家可能会奇怪它为什么值得如此重视,为什么还有这么多的人认为它是计算机程序设计的一个里程碑呢?如果您来自一个传统的程序设计背景,那么答案在刚开始的时候并不是很明显。
Java的面向对象编程外文资料翻译
毕业设计(论文)外文资料翻译系:计算机系专业:计算机科学与技术姓名:学号:外文出处:Ghosh,D..Java Object-oriented(用外文写)programming[J]. IEEE Transactionson SoftwareEngineering,2009, 13(3):42-45.附件: 1.外文资料翻译译文;2.外文原文。
注:请将该封面与附件装订成册。
附件1:外文资料翻译译文Java的面向对象编程——面向对象编程和它的关键技术—继承和多态性软件的重用可以节省程序开发时间。
它鼓励重复使用已经调试好的高质量的软件,从而减少系统运行后可能出现的问题。
这些都是令人振奋的可能性。
多态性允许我们用统一的风格编写程序,来处理多种已存在的类和特定的相关类。
利用多态性我们可以方便地向系统中添加新的功能。
继承和多态对于解决软件的复杂性是一种有效可行的技术。
当创建一个新的类时,而不用完整的写出新的实例变量和实例方法,程序员会指定新的类继承已定义的超类的实例变量和实例方法。
这个新的类被称为一个子类。
每个子类本身将来亦可有新的子类,而其本身将成为父类。
一个类的直接父类就是该类所直接继承的类(通过关键字extends继承)。
一个间接超类是通过从两级或更多级以上的类继承而来的。
例如,从类JApplet(包javax.swing 中)扩展来的类Applet(包java.applet)。
一个类单一的从一个父类继承而来。
Java 不支持多重继承(而C++可以),但它支持接口的概念。
接口可以使Java实现许多通过多重继承才能实现的优点而没有关联的问题。
我们将在本章讨论的接口的详细内容。
我们会给出创建和使用接口的一般规律和具体实例。
一个子类通常添加自己的实例变量和自己的实例方法,因此子类通常比父类大。
一个子类比它的父类更具体并且代表一组更小、更专业的对象。
通过单一继承,子类在开始时拥有父类的所有特性。
继承性真正的力量在于它可以在定义子类时增加或取代从超类中继承来的特征。
计算机java外文翻译外文文献英文文献
英文原文:Title: Business Applications of Java. Author: Erbschloe, Michael, Business Applications of Java -- Research Starters Business, 2008DataBase: Research Starters - BusinessBusiness Applications of JavaThis article examines the growing use of Java technology in business applications. The history of Java is briefly reviewed along with the impact of open standards on the growth of the World Wide Web. Key components and concepts of the Java programming language are explained including the Java Virtual Machine. Examples of how Java is being used bye-commerce leaders is provided along with an explanation of how Java is used to develop data warehousing, data mining, and industrial automation applications. The concept of metadata modeling and the use of Extendable Markup Language (XML) are also explained.Keywords Application Programming Interfaces (API's); Enterprise JavaBeans (EJB); Extendable Markup Language (XML); HyperText Markup Language (HTML); HyperText Transfer Protocol (HTTP); Java Authentication and Authorization Service (JAAS); Java Cryptography Architecture (JCA); Java Cryptography Extension (JCE); Java Programming Language; Java Virtual Machine (JVM); Java2 Platform, Enterprise Edition (J2EE); Metadata Business Information Systems > Business Applications of JavaOverviewOpen standards have driven the e-business revolution. Networking protocol standards, such as Transmission Control Protocol/Internet Protocol (TCP/IP), HyperText Transfer Protocol (HTTP), and the HyperText Markup Language (HTML) Web standards have enabled universal communication via the Internet and the World Wide Web. As e-business continues to develop, various computing technologies help to drive its evolution.The Java programming language and platform have emerged as major technologies for performing e-business functions. Java programming standards have enabled portability of applications and the reuse of application components across computing platforms. Sun Microsystems' Java Community Process continues to be a strong base for the growth of the Java infrastructure and language standards. This growth of open standards creates new opportunities for designers and developers of applications and services (Smith, 2001).Creation of Java TechnologyJava technology was created as a computer programming tool in a small, secret effort called "the Green Project" at Sun Microsystems in 1991. The Green Team, fully staffed at 13 people and led by James Gosling, locked themselves away in an anonymous office on Sand Hill Road in Menlo Park, cut off from all regular communications with Sun, and worked around the clock for18 months. Their initial conclusion was that at least one significant trend would be the convergence of digitally controlled consumer devices and computers. A device-independent programming language code-named "Oak" was the result.To demonstrate how this new language could power the future of digital devices, the Green Team developed an interactive, handheld home-entertainment device controller targeted at the digital cable television industry. But the idea was too far ahead of its time, and the digital cable television industry wasn't ready for the leap forward that Java technology offered them. As it turns out, the Internet was ready for Java technology, and just in time for its initial public introduction in 1995, the team was able to announce that the Netscape Navigator Internet browser would incorporate Java technology ("Learn about Java," 2007).Applications of JavaJava uses many familiar programming concepts and constructs and allows portability by providing a common interface through an external Java Virtual Machine (JVM). A virtual machine is a self-contained operating environment, created by a software layer that behaves as if it were a separate computer. Benefits of creating virtual machines include better exploitation of powerful computing resources and isolation of applications to prevent cross-corruption and improve security (Matlis, 2006).The JVM allows computing devices with limited processors or memory to handle more advanced applications by calling up software instructions inside the JVM to perform most of the work. This also reduces the size and complexity of Java applications because many of the core functions and processing instructions were built into the JVM. As a result, software developersno longer need to re-create the same application for every operating system. Java also provides security by instructing the application to interact with the virtual machine, which served as a barrier between applications and the core system, effectively protecting systems from malicious code.Among other things, Java is tailor-made for the growing Internet because it makes it easy to develop new, dynamic applications that could make the most of the Internet's power and capabilities. Java is now an open standard, meaning that no single entity controls its development and the tools for writing programs in the language are available to everyone. The power of open standards like Java is the ability to break down barriers and speed up progress.Today, you can find Java technology in networks and devices that range from the Internet and scientific supercomputers to laptops and cell phones, from Wall Street market simulators to home game players and credit cards. There are over 3 million Java developers and now there are several versions of the code. Most large corporations have in-house Java developers. In addition, the majority of key software vendors use Java in their commercial applications (Lazaridis, 2003).ApplicationsJava on the World Wide WebJava has found a place on some of the most popular websites in the world and the uses of Java continues to grow. Java applications not only provide unique user interfaces, they also help to power the backend of websites. Two e-commerce giants that everybody is probably familiar with (eBay and Amazon) have been Java pioneers on the World Wide Web.eBayFounded in 1995, eBay enables e-commerce on a local, national and international basis with an array of Web sites-including the eBay marketplaces, PayPal, Skype, and -that bring together millions of buyers and sellers every day. You can find it on eBay, even if you didn't know it existed. On a typical day, more than 100 million items are listed on eBay in tens of thousands of categories. Recent listings have included a tunnel boring machine from the Chunnel project, a cup of water that once belonged to Elvis, and the Volkswagen that Pope Benedict XVI owned before he moved up to the Popemobile. More than one hundred million items are available at any given time, from the massive to the miniature, the magical to the mundane, on eBay; the world's largest online marketplace.eBay uses Java almost everywhere. To address some security issues, eBay chose Sun Microsystems' Java System Identity Manager as the platform for revamping its identity management system. The task at hand was to provide identity management for more than 12,000 eBay employees and contractors.Now more than a thousand eBay software developers work daily with Java applications. Java's inherent portability allows eBay to move to new hardware to take advantage of new technology, packaging, or pricing, without having to rewrite Java code ("eBay drives explosive growth," 2007).Amazon (a large seller of books, CDs, and other products) has created a Web Service application that enables users to browse their product catalog and place orders. uses a Java application that searches the Amazon catalog for books whose subject matches a user-selected topic. The application displays ten books that match the chosen topic, and shows the author name, book title, list price, Amazon discount price, and the cover icon. The user may optionally view one review per displayed title and make a buying decision (Stearns & Garishakurthi, 2003).Java in Data Warehousing & MiningAlthough many companies currently benefit from data warehousing to support corporate decision making, new business intelligence approaches continue to emerge that can be powered by Java technology. Applications such as data warehousing, data mining, Enterprise Information Portals (EIP's), and Knowledge Management Systems (which can all comprise a businessintelligence application) are able to provide insight into customer retention, purchasing patterns, and even future buying behavior.These applications can not only tell what has happened but why and what may happen given certain business conditions; allowing for "what if" scenarios to be explored. As a result of this information growth, people at all levels inside the enterprise, as well as suppliers, customers, and others in the value chain, are clamoring for subsets of the vast stores of information such as billing, shipping, and inventory information, to help them make business decisions. While collecting and storing vast amounts of data is one thing, utilizing and deploying that data throughout the organization is another.The technical challenges inherent in integrating disparate data formats, platforms, and applications are significant. However, emerging standards such as the Application Programming Interfaces (API's) that comprise the Java platform, as well as Extendable Markup Language (XML) technologies can facilitate the interchange of data and the development of next generation data warehousing and business intelligence applications. While Java technology has been used extensively for client side access and to presentation layer challenges, it is rapidly emerging as a significant tool for developing scaleable server side programs. The Java2 Platform, Enterprise Edition (J2EE) provides the object, transaction, and security support for building such systems.Metadata IssuesOne of the key issues that business intelligence developers must solve is that of incompatible metadata formats. Metadata can be defined as information about data or simply "data about data." In practice, metadata is what most tools, databases, applications, and other information processes use to define, relate, and manipulate data objects within their own environments. It defines the structure and meaning of data objects managed by an application so that the application knows how to process requests or jobs involving those data objects. Developers can use this schema to create views for users. Also, users can browse the schema to better understand the structure and function of the database tables before launching a query.To address the metadata issue, a group of companies (including Unisys, Oracle, IBM, SAS Institute, Hyperion, Inline Software and Sun) have joined to develop the Java Metadata Interface (JMI) API. The JMI API permits the access and manipulation of metadata in Java with standard metadata services. JMI is based on the Meta Object Facility (MOF) specification from the Object Management Group (OMG). The MOF provides a model and a set of interfaces for the creation, storage, access, and interchange of metadata and metamodels (higher-level abstractions of metadata). Metamodel and metadata interchange is done via XML and uses the XML Metadata Interchange (XMI) specification, also from the OMG. JMI leverages Java technology to create an end-to-end data warehousing and business intelligence solutions framework.Enterprise JavaBeansA key tool provided by J2EE is Enterprise JavaBeans (EJB), an architecture for the development of component-based distributed business applications. Applications written using the EJB architecture are scalable, transactional, secure, and multi-user aware. These applications may be written once and then deployed on any server platform that supports J2EE. The EJB architecture makes it easy for developers to write components, since they do not need to understand or deal with complex, system-level details such as thread management, resource pooling, and transaction and security management. This allows for role-based development where component assemblers, platform providers and application assemblers can focus on their area of responsibility further simplifying application development.EJB's in the Travel IndustryA case study from the travel industry helps to illustrate how such applications could function. A travel company amasses a great deal of information about its operations in various applications distributed throughout multiple departments. Flight, hotel, and automobile reservation information is located in a database being accessed by travel agents worldwide. Another application contains information that must be updated with credit and billing historyfrom a financial services company. Data is periodically extracted from the travel reservation system databases to spreadsheets for use in future sales and marketing analysis.Utilizing J2EE, the company could consolidate application development within an EJB container, which can run on a variety of hardware and software platforms allowing existing databases and applications to coexist with newly developed ones. EJBs can be developed to model various data sets important to the travel reservation business including information about customer, hotel, car rental agency, and other attributes.Data Storage & AccessData stored in existing applications can be accessed with specialized connectors. Integration and interoperability of these data sources is further enabled by the metadata repository that contains metamodels of the data contained in the sources, which then can be accessed and interchanged uniformly via the JMI API. These metamodels capture the essential structure and semantics of business components, allowing them to be accessed and queried via the JMI API or to be interchanged via XML. Through all of these processes, the J2EE infrastructure ensures the security and integrity of the data through transaction management and propagation and the underlying security architecture.To consolidate historical information for analysis of sales and marketing trends, a data warehouse is often the best solution. In this example, data can be extracted from the operational systems with a variety of Extract, Transform and Load tools (ETL). The metamodels allow EJBsdesigned for filtering, transformation, and consolidation of data to operate uniformly on datafrom diverse data sources as the bean is able to query the metamodel to identify and extract the pertinent fields. Queries and reports can be run against the data warehouse that contains information from numerous sources in a consistent, enterprise-wide fashion through the use of the JMI API (Mosher & Oh, 2007).Java in Industrial SettingsMany people know Java only as a tool on the World Wide Web that enables sites to perform some of their fancier functions such as interactivity and animation. However, the actual uses for Java are much more widespread. Since Java is an object-oriented language like C++, the time needed for application development is minimal. Java also encourages good software engineering practices with clear separation of interfaces and implementations as well as easy exception handling.In addition, Java's automatic memory management and lack of pointers remove some leading causes of programming errors. Most importantly, application developers do not need to create different versions of the software for different platforms. The advantages available through Java have even found their way into hardware. The emerging new Java devices are streamlined systems that exploit network servers for much of their processing power, storage, content, and administration.Benefits of JavaThe benefits of Java translate across many industries, and some are specific to the control and automation environment. For example, many plant-floor applications use relatively simple equipment; upgrading to PCs would be expensive and undesirable. Java's ability to run on any platform enables the organization to make use of the existing equipment while enhancing the application.IntegrationWith few exceptions, applications running on the factory floor were never intended to exchange information with systems in the executive office, but managers have recently discovered the need for that type of information. Before Java, that often meant bringing together data from systems written on different platforms in different languages at different times. Integration was usually done on a piecemeal basis, resulting in a system that, once it worked, was unique to the two applications it was tying together. Additional integration required developing a brand new system from scratch, raising the cost of integration.Java makes system integration relatively easy. Foxboro Controls Inc., for example, used Java to make its dynamic-performance-monitor software package Internet-ready. This software provides senior executives with strategic information about a plant's operation. The dynamic performance monitor takes data from instruments throughout the plant and performs variousmathematical and statistical calculations on them, resulting in information (usually financial) that a manager can more readily absorb and use.ScalabilityAnother benefit of Java in the industrial environment is its scalability. In a plant, embedded applications such as automated data collection and machine diagnostics provide critical data regarding production-line readiness or operation efficiency. These data form a critical ingredient for applications that examine the health of a production line or run. Users of these devices can take advantage of the benefits of Java without changing or upgrading hardware. For example, operations and maintenance personnel could carry a handheld, wireless, embedded-Java device anywhere in the plant to monitor production status or problems.Even when internal compatibility is not an issue, companies often face difficulties when suppliers with whom they share information have incompatible systems. This becomes more of a problem as supply-chain management takes on a more critical role which requires manufacturers to interact more with offshore suppliers and clients. The greatest efficiency comes when all systems can communicate with each other and share information seamlessly. Since Java is so ubiquitous, it often solves these problems (Paula, 1997).Dynamic Web Page DevelopmentJava has been used by both large and small organizations for a wide variety of applications beyond consumer oriented websites. Sandia, a multiprogram laboratory of the U.S. Department of Energy's National Nuclear Security Administration, has developed a unique Java application. The lab was tasked with developing an enterprise-wide inventory tracking and equipment maintenance system that provides dynamic Web pages. The developers selected Java Studio Enterprise 7 for the project because of its Application Framework technology and Web Graphical User Interface (GUI) components, which allow the system to be indexed by an expandable catalog. The flexibility, scalability, and portability of Java helped to reduce development timeand costs (Garcia, 2004)IssueJava Security for E-Business ApplicationsTo support the expansion of their computing boundaries, businesses have deployed Web application servers (WAS). A WAS differs from a traditional Web server because it provides a more flexible foundation for dynamic transactions and objects, partly through the exploitation of Java technology. Traditional Web servers remain constrained to servicing standard HTTP requests, returning the contents of static HTML pages and images or the output from executed Common Gateway Interface (CGI ) scripts.An administrator can configure a WAS with policies based on security specifications for Java servlets and manage authentication and authorization with Java Authentication andAuthorization Service (JAAS) modules. An authentication and authorization service can bewritten in Java code or interface to an existing authentication or authorization infrastructure. Fora cryptography-based security infrastructure, the security server may exploit the Java Cryptography Architecture (JCA) and Java Cryptography Extension (JCE). To present the user with a usable interaction with the WAS environment, the Web server can readily employ a formof "single sign-on" to avoid redundant authentication requests. A single sign-on preserves user authentication across multiple HTTP requests so that the user is not prompted many times for authentication data (i.e., user ID and password).Based on the security policies, JAAS can be employed to handle the authentication process with the identity of the Java client. After successful authentication, the WAS securitycollaborator consults with the security server. The WAS environment authentication requirements can be fairly complex. In a given deployment environment, all applications or solutions may not originate from the same vendor. In addition, these applications may be running on different operating systems. Although Java is often the language of choice for portability between platforms, it needs to marry its security features with those of the containing environment.Authentication & AuthorizationAuthentication and authorization are key elements in any secure information handling system. Since the inception of Java technology, much of the authentication and authorization issues have been with respect to downloadable code running in Web browsers. In many ways, this had been the correct set of issues to address, since the client's system needs to be protected from mobile code obtained from arbitrary sites on the Internet. As Java technology moved from a client-centric Web technology to a server-side scripting and integration technology, it required additional authentication and authorization technologies.The kind of proof required for authentication may depend on the security requirements of a particular computing resource or specific enterprise security policies. To provide such flexibility, the JAAS authentication framework is based on the concept of configurable authenticators. This architecture allows system administrators to configure, or plug in, the appropriate authenticatorsto meet the security requirements of the deployed application. The JAAS architecture also allows applications to remain independent from underlying authentication mechanisms. So, as new authenticators become available or as current authentication services are updated, system administrators can easily replace authenticators without having to modify or recompile existing applications.At the end of a successful authentication, a request is associated with a user in the WAS user registry. After a successful authentication, the WAS consults security policies to determine if the user has the required permissions to complete the requested action on the servlet. This policy canbe enforced using the WAS configuration (declarative security) or by the servlet itself (programmatic security), or a combination of both.The WAS environment pulls together many different technologies to service the enterprise. Because of the heterogeneous nature of the client and server entities, Java technology is a good choice for both administrators and developers. However, to service the diverse security needs of these entities and their tasks, many Java security technologies must be used, not only at a primary level between client and server entities, but also at a secondary level, from served objects. By using a synergistic mix of the various Java security technologies, administrators and developers can make not only their Web application servers secure, but their WAS environments secure as well (Koved, 2001).ConclusionOpen standards have driven the e-business revolution. As e-business continues to develop, various computing technologies help to drive its evolution. The Java programming language and platform have emerged as major technologies for performing e-business functions. Java programming standards have enabled portability of applications and the reuse of application components. Java uses many familiar concepts and constructs and allows portability by providing a common interface through an external Java Virtual Machine (JVM). Today, you can find Java technology in networks and devices that range from the Internet and scientific supercomputers to laptops and cell phones, from Wall Street market simulators to home game players and credit cards.Java has found a place on some of the most popular websites in the world. Java applications not only provide unique user interfaces, they also help to power the backend of websites. While Java technology has been used extensively for client side access and in the presentation layer, it is also emerging as a significant tool for developing scaleable server side programs.Since Java is an object-oriented language like C++, the time needed for application development is minimal. Java also encourages good software engineering practices with clear separation of interfaces and implementations as well as easy exception handling. Java's automatic memory management and lack of pointers remove some leading causes of programming errors. The advantages available through Java have also found their way into hardware. The emerging new Java devices are streamlined systems that exploit network servers for much of their processing power, storage, content, and administration.中文翻译:标题:Java的商业应用。
JAVA毕业设计外文文献翻译
THE TECHNIQUE DEVELOPMENT HISTORY OF JSPBy:Kathy Sierra and Bert BatesSource: Servlet&JSPThe Java Server Pages( JSP) is a kind of according to web of the script plait distance technique, similar carries the script language of Java in the server of the Netscape company of server- side JavaScript( SSJS) and the Active Server Pages(ASP) of the Microsoft. JSP compares the SSJS and ASP to have better can expand sex, and it is no more exclusive than any factory or some one particular server of Web. Though the norm of JSP is to be draw up by the Sun company of, any factory can carry out the JSP on own system.The After Sun release the JS P( the Java Server Pages) formally, the this kind of new Web application development technique very quickly caused the people's concern. JSP provided a special development environment for the Webapplication that establishes the high dynamic state. According to the Sun parlance, the JSP can adapt to include the Apache WebServer, IIS4.0 on themarket at inside of 85% server product.This chapter will introduce the related knowledge of JSP and Databases, and JavaBean related contents, is all certainly rougher introduction among them basic contents, say perhaps to is a Guide only, if the reader needs the more detailed information, pleasing the book of consult the homologous JSP.1.1 GENER ALIZEThe JSP(Java Server Pages) is from the company of Sun Microsystems initiate, the many companies the participate to the build up the together of the a kind the of dynamic the state web the page technique standard, the it have the it in the construction the of the dynamic state the web page the strong but the do not the especially of the function. JSP and the technique of ASP of the Microsoft is very alike. Both all provide the ability that mixes with a certain procedure code and is explain by the language engine to carry out the procedure code in the code of HTML. Underneath we are simple of carry on the introduction to it.JSP pages are translated into servlets. So, fundamentally, any task JSP pages can perform could also be accomplished by servlets. However, this underlying equivalence does not mean that servlets and JSP pages are equally appropriatein all scenarios. The issue is not the power of the technology, it is the convenience, productivity, and maintainability of one or the other. After all, anything you can do on a particular computer platform in the Java programming language you could also do in assembly language. But it still matters which youchoose.JSP provides the following benefits over servlets alone: • It is easier to write and maintain the HTML. Your static code is ordinary HTML: no extra backslashes, no double quotes, and no lurking Java syntax.• You can use standard Web-site development tools. Even HTML tools that know nothing about JSP can be used because they simply ignore the JSP tags. • You can divide up your development team. The Java programmers can work on the dynamic code. The Web developers can concentrate on the presentation layer. On large projects, this division is very important. Depending on the size of your team and the complexity of your project, you can enforce a weaker or stronger separation between the static HTML and the dynamic content. Now, this discussion is not to say that you should stop using servlets and use only JSP instead. By no means. Almost all projects will use both. For some requests in your project, you will use servlets. For others, you will use JSP. For still others, you will combine them with the MVC architecture . You want the apGFDGpropriate tool for the job, and servlets, by themselves, do not completeyour toolkit.1.2 SOURCE OF JSPThe technique of JSP of the company of Sun, making the page of Web develop the personnel can use the HTML perhaps marking of XML to design to turn the end page with format. Use the perhaps small script future life of marking of JSP becomes the dynamic state on the page contents.( the contents changesaccording to the claim of)The Java Servlet is a technical foundation of JSP, and the large Web applies the development of the procedure to need the Java Servlet to match with with the JSP and then can complete, this name of Servlet comes from the Applet, the local translation method of now is a lot of, this book in order not to misconstruction, decide the direct adoption Servlet but don't do any translation, if reader would like to, can call it as" small service procedure". The Servlet is similar to traditional CGI, ISAPI, NSAPI etc. Web procedure development the function of the tool in fact, at use the Java Servlet hereafter, the customer neednot use again the lowly method of CGI of efficiency, also need not use only the ability come to born page of Web of dynamic state in the method of API that a certain fixed Web server terrace circulate. Many servers of Web all support the Servlet, even not support the Servlet server of Web directly and can also pass the additional applied server and the mold pieces to support the Servlet. Receive benefit in the characteristic of the Java cross-platform, the Servlet is also a terrace irrelevant, actually, as long as match the norm of Java Servlet, the Servlet is complete to have nothing to do with terrace and is to have nothing to do with server of Web. Because the Java Servlet is internal to provide the service by the line distance, need not start a progress to the each claimses, and make use of the multi-threading mechanism can at the same time for several claim service, therefore the efficiency of Java Servlet is very high.But the Java Servlet also is not to has no weakness, similar to traditional CGI, ISAPI, the NSAPI method, the Java Servlet is to make use of to output the HTML language sentence to carry out the dynamic state web page of, if develop the whole website with the Java Servlet, the integration process of the dynamic state part and the static state page is an evil-foreboding dream simply. For solving this kind of weakness of the Java Servlet, the SUN released the JSP.A number of years ago, Marty was invited to attend a small 20-person industry roundtable discussion on software technology. Sitting in the seat next to Marty was James Gosling, inventor of the Java programming language. Sitting several seats away was a high-level manager from a very large software company in Redmond, Washington. During the discussion, the moderator brought up the subject of Jini, which at that time was a new Java technology. The moderator asked the manager what he thought of it, and the manager responded that it was too early to tell, but that it seemed to be an excellent idea. He went on to say that they would keep an eye on it, and if it seemed to be catching on, they would follow his company's usual "embrace and extend" strategy. At this point,Gosling lightheartedly interjected "You mean disgrace and distend." Now, the grievance that Gosling was airing was that he felt that this company would take technology from other companies and suborn it for their ownpurposes. But guess what? The shoe is on the other foot here. The Java community did not invent the idea of designing pages as a mixture of static HTML and dynamic code marked with special tags. For example, Cold Fusion did it years earlier. Even ASP (a product from the very software company of theaforementioned manager) popularized this approach before JSP came along and decided to jump on the bandwagon. In fact, JSP not only adopted the general idea, it even used many of the same special tags as ASP did.The JSP is an establishment at the model of Java servlets on of the expression layer technique, it makes the plait write the HTML to become more simple.Be like the SSJS, it also allows you carry the static state HTML contents and servers the script mix to put together the born dynamic state exportation. JSP the script language that the Java is the tacit approval, however, be like the ASP and can use other languages( such as JavaScript and VBScript), the norm of JSP alsoallows to use other languages.1.3JSP CHARACTERISTICSIs a service according to the script language in some one language of the statures system this kind of discuss, the JSP should be see make is a kind of script language. However, be a kind of script language, the JSP seemed to be too strong again, almost can use all Javas in the JSP.Be a kind of according to text originally of, take manifestation as the central development technique, the JSP provided all advantages of the Java Servlet, and, when combine with a JavaBeans together, providing a kind of make contents and manifestation that simple way that logic separate. Separate the contents and advantage of logical manifestations is, the personnel who renews the page external appearance need not know the code of Java, and renew the JavaBeans personnel also need not be design the web page of expert in hand, can use to take the page of JavaBeans JSP to define the template of Web, to build up a from have the alike external appearance of the website that page constitute. JavaBeans completes the data to provide, having no code of Java in the template thus, this means that these templates can be written the personnel by a HTML plait to support. Certainly, can also make use of the Java Servlet to control the logic of the website, adjust through the Java Servlet to use the way of the document of JSP to separate website of logic and contents.Generally speaking, in actual engine of JSP, the page of JSP is the edit and translate type while carry out, not explain the type of. Explain the dynamic state web page development tool of the type, such as ASP, PHP3 etc., because speed etc. reason, have already can't satisfy current the large electronic commerce needs appliedly, traditional development techniques are all at to edit and translate the executive way change, such as the ASP → ASP+;PHP3 → PHP4.In the JSP norm book, did not request the procedure in the JSP code part( be called the Scriptlet) and must write with the Java definitely. Actually, have some engines of JSP are adoptive other script languages such as the EMAC- Script, etc., but actually this a few script languages also are to set up on the Java, edit and translate for the Servlet to carry out of. Write according to the norm of JSP, have no Scriptlet of relation with Java also is can of, however, mainly lie in the ability and JavaBeans, the Enterprise JavaBeanses because of the JSP strong function to work together, so even is the Scriptlet part not to use the Java, edit and translate of performance code also should is related with Java.1.4JSP MECHANISMTo comprehend the JSP how unite the technical advantage that above various speak of, come to carry out various result easily, the customer must understand the differentiation of" the module develops for the web page of the center" and"the page develops for the web page of the center" first.The SSJS and ASP are all in several year ago to release, the network of that time is still very young, no one knows to still have in addition to making all business, datas and the expression logic enter the original web page entirely heap what better solve the method. This kind of model that take page as the center studies and gets the very fast development easily. However, along with change of time, the people know that this kind of method is unwell in set up large, the Web that can upgrade applies the procedure. The expression logic write in the script environment was lock in the page, only passing to shear to slice and glue to stick then can drive heavy use. Express the logic to usually mix together with business and the data logics, when this makes be the procedure member to try to change an external appearance that applies the procedure but do not want to break with its llied business logic, apply the procedure of maintenance be like to walk the similar difficulty on the eggshell. In fact in the business enterprise, heavy use the application of the module already through very mature, no one would like to rewrite those logics for their applied procedure.HTML and sketch the designer handed over to the implement work of their design the Web plait the one who write, make they have to double work- Usually is the handicraft plait to write, because have no fit tool and can carry the script and the HTML contents knot to the server to put together. Chien but speech, apply the complexity of the procedure along with the Web to promote continuously, the development method that take page as the center limits sex to become to get up obviously.At the same time, the people always at look for the better method of build up the Web application procedure, the module spreads in customer's machine/ server the realm. JavaBeans and ActiveX were published the company to expand to apply the procedure developer for Java and Windows to use to come to develop the complicated procedure quickly by" the fast application procedure development"( RAD) tool. These techniques make the expert in the some realm be able to write the module for the perpendicular application plait in the skill area, but the developer can go fetch the usage directly but need not control the expertise of this realm.Be a kind of take module as the central development terrace, the JSP appeared. It with the JavaBeans and Enterprise JavaBeans( EJB) module includes the model of the business and the data logic for foundation, provide a great deal of label and a script terraces to use to come to show in the HTML page from the contents of JavaBeans creation or send a present in return. Because of the property that regards the module as the center of the JSP, it can drive Java and not the developer of Java uses equally. Not the developer of Java can pass the JSP label( Tags) to use the JavaBeans that the deluxe developer of Java establish. The developer of Java not only can establish and use the JavaBeans, but also can use the language of Java to come to control more accurately in the JSP page according to the expression logic of the first floor JavaBeans.See now how JSP is handle claim of HTTP. In basic claim model, a claim directly was send to JSP page in. The code of JSP controls to carry on hour of the logic processing and module of JavaBeanses' hand over with each other, and the manifestation result in dynamic state bornly, mixing with the HTML page of the static state HTML code. The Beans can be JavaBeans or module of EJBs.Moreover, the more complicated claim model can see make from is request other JSP pages of the page call sign or Java Servlets.The engine of JSP wants to chase the code of Java that the label of JSP, code of Java in the JSP page even all converts into the big piece together with the static state HTML contents actually. These codes piece was organized the Java Servlet that customer can not see to go to by the engine of JSP, then the Servlet edits and translate them automatically byte code of Java.Thus, the visitant that is the website requests a JSP page, under the condition of it is not knowing, an already born, the Servlet actual full general that prepared to edit and translate completes all works, very concealment but again andefficiently. The Servlet is to edit and translate of, so the code of JSP in the web page does not need when the every time requests that page is explain. The engine of JSP need to be edit and translate after Servlet the code end is modify only once, then this Servlet that editted and translate can be carry out. The in view of the fact JSP engine auto is born to edit and translate the Servlet also, need not procedure member begins to edit and translate the code, so the JSP can bring vivid sex that function and fast developments need that you are efficiently. Compared with the traditional CGI, the JSP has the equal advantage. First, on the speed, the traditional procedure of CGI needs to use the standard importation of the system to output the equipments to carry out the dynamic state web page born, but the JSP is direct is mutually the connection with server. And say for the CGI, each interview needs to add to add a progress to handle, the progress build up and destroy by burning constantly and will be a not small burden for calculator of be the server of Web. The next in order, the JSP is specialized to develop but design for the Web of, its purpose is for building up according to the Web applied procedure, included the norm and the tool of a the whole set. Use the technique of JSP can combine a lot of JSP pages to become a Webapplication procedure very expediently.JSP的技术发展历史作者:Kathy Sierra and Bert Bates来源:Servlet&JSPJava Server Pages(JSP)是一种基于web的脚本编程技术,类似于网景公司的服务器端Java脚本语言——server-side JavaScript(SSJS)和微软的Active Server Pages(ASP)。
Java技术介绍-毕业论文外文翻译
Java Technical DescriptionJava as a Programming Platform.Java is certainly a good programming language. There is no doubt that it is one of the better languages available to serious programmers. We think it could potentially have been a great programming language, but it is probably too late for that. Once a language is out in the field, the ugly reality of compatibility with existing code sets in."Java was never just a language. There are lots of programming languages out there, and few of them make much of a splash. Java is a whole platform, with a huge library, containing lots of reusable code, and an execution environment that provides services such as security, portability across operating systems, and automatic garbage collection.As a programmer, you will want a language with a pleasant syntax and comprehensible semantics (i.e., not C++). Java fits the bill, as do dozens of other fine languages. Some languages give you portability, garbage collection, and the like, but they don't have much of a library, forcing you to roll your own if you want fancy graphics or networking or database access. Well, Java has everything—a good language, a high-quality execution environment, and a vast library. That combination is what makes Java an irresistible proposition to so many programmers.Features of Java.1.SimpleWe wanted to build a system that could be programmed easily without a lot of esoteric training and which leveraged today's standard practice. So even though we found that C++ was unsuitable, we designed Java as closely to C++ as possible in order to make the system more comprehensible. Java omits many rarely used, poorly understood, confusing features of C++ that, in our experience, bring more grief than benefit.The syntax for Java is, indeed, a cleaned-up version of the syntax for C++. There is no need for header files, pointer arithmetic (or even a pointer syntax), structures, unions, operator overloading, virtual base classes, and so on. (See the C++ notes interspersed throughout the text for more on the differences between Java and C++.) The designers did not, however, attempt to fix all of the clumsy features of C++. For example, the syntax of the switch statement is unchanged in Java. If you know C++, you will find the transition to the Java syntax easy.If you are used to a visual programming environment (such as Visual Basic), you will not find Java simple. There is much strange syntax (though it does not take long to get the hang of it). More important, you must do a lot more programming in Java. The beauty of Visual Basic is that its visual design environment almost automatically provides a lot of the infrastructure for an application. The equivalent functionality must be programmed manually, usually with a fair bit of code, in Java. There are, however, third-party development environments that provide "drag-and-drop"-style program development.Another aspect of being simple is being small. One of the goals of Java is to enable the construction of software that can run stand-alone in small machines. The size of the basic interpreter and class support is about 40K bytes; adding the basic standard libraries and thread support (essentially a self-contained microkernel) adds an additional 175K.2. Object OrientedSimply stated, object-oriented design is a technique for programming that focuses on the data (= objects) and on the interfaces to that object. To make an analogy with carpentry, an "object-oriented" carpenter would be mostly concerned with the chair he was building, and secondarily with the tools used to make it; a "non-object-oriented" carpenter would think primarily of his tools. The object-oriented facilities of Java are essentially those of C++.Object orientation has proven its worth in the last 30 years, and it is inconceivable that a modern programming language would not use it. Indeed, the object-oriented features of Java are comparable to those of C++. The major differencebetween Java and C++ lies in multiple inheritance, which Java has replaced with the simpler concept of interfaces, and in the Java metaclass model. The reflection mechanism and object serialization feature make it much easier to implement persistent objects and GUI builders that can integrate off-the-shelf components.3. DistributedJava has an extensive library of routines for coping with TCP/IP protocols like HTTP and FTP. Java applications can open and access objects across the Net via URLs with the same ease as when accessing a local file system. We have found the networking capabilities of Java to be both strong and easy to use. Anyone who has tried to do Internet programming using another language will revel in how simple Java makes onerous tasks like opening a socket connection. (We cover networking in Volume 2 of this book.) The remote method invocation mechanism enables communication between distributedobjects (also covered in Volume 2).There is now a separate architecture, the Java 2 Enterprise Edition (J2EE), that supports very large scale distributed applications.4. RobustJava is intended for writing programs that must be reliable in a variety of ways. Java puts a lot of emphasis on early checking for possible problems, later dynamic (run-time) checking, and eliminating situations that are error-prone.… The single biggest difference between Java and C/C++ is that Java has a pointer model that eliminates the possibility of overwriting memory and corrupting data.This feature is also very useful. The Java compiler detects many problems that, in other languages, would show up only at run time. As for the second point, anyone who has spent hours chasing memory corruption caused by a pointer bug will be very happy with this feature of Java.If you are coming from a language like Visual Basic that doesn't explicitly use pointers, you are probably wondering why this is so important. C programmers are not so lucky. They need pointers to access strings, arrays, objects, and even files. In Visual Basic, you do not use pointers for any of these entities, nor do you need to worry about memory allocation for them. On the other hand, many data structures aredifficult to implement in a pointerless language. Java gives you the best of both worlds. You do not need pointers for everyday constructs like strings and arrays. You have the power of pointers if you need it, for example, for linked lists. And you always have complete safety, because you can never access a bad pointer, make memory allocation errors, or have to protect against memory leaking away.5. SecureJava is intended to be used in networked/distributed environments. Toward that end, a lot of emphasis has been placed on security. Java enables the construction of virus-free, tamper-free systems.In the first edition of Core Java we said: "Well, one should 'never say never again,'" and we turned out to be right. Not long after the first version of the Java Development Kit was shipped, a group of security experts at Princeton University found subtle bugs in the security features of Java 1.0. Sun Microsystems has encouraged research into Java security, making publicly available the specification and implementation of the virtual machine and the security libraries. They have fixed all known security bugs quickly. In any case, Java makes it extremely difficult to outwit its security mechanisms. The bugs found so far have been very technical and few in number. From the beginning, Java was designed to make certain kinds of attacks impossible, among them:∙Overrunning the runtime stack—a common attack of worms and viruses Corrupting memory outside its own process space Reading or writing files without permission.∙A number of security features have been added to Java over time. Since version1.1, Java has the notion of digitally signed classesWith a signed class, you can be sure who wrote it. Any time you trust the author of the class, the class can be allowed more privileges on your machine.6. Architecture NeutralThe compiler generates an architecture-neutral object file format—the compiled code is executable on many processors, given the presence of the Java runtime system.The Java compiler does this by generating bytecode instructions which have nothing to do with a particular computerarchitecture. Rather, they are designed to be both easy to interpret on any machine and easily translated into native machine code on the fly.This is not a new idea. More than 20 years ago, both Niklaus Wirth's original implementation of Pascal and the UCSD Pascal system used the same technique. Of course, interpreting bytecodes is necessarily slower than running machine instructions at full speed, so it isn't clear that this is even a good idea. However, virtual machines have the option of translating the most frequently executed bytecode sequences into machine code, a process called just-in-time compilation. This strategy has proven so effective that even Microsoft's .NET platform relies on a virtual machine.The virtual machine has other advantages. It increases security because the virtual machine can check the behavior of instruction sequences. Some programs even produce bytecodes on the fly, dynamically enhancing the capabilities of a running program.7. PortableUnlike C and C++, there are no "implementation-dependent" aspects of the specification. The sizes of the primitive data types are specified, as is the behavior of arithmetic on them.For example, an int in Java is always a 32-bit integer. In C/C++, int can mean a 16-bit integer, a 32-bit integer, or any other size that the compiler vendor likes. The only restriction is that the int type must have at least as many bytes as a short int and cannot have more bytes than a long int. Having a fixed size for number types eliminates a major porting headache. Binary data is stored and transmitted in a fixed format, eliminating confusion about byte ordering. Strings are saved in a standard Unicode format.The libraries that are a part of the system define portable interfaces. For example, there is an abstract Window class and implementations of it for UNIX, Windows, and the Macintosh.As anyone who has ever tried knows, it is an effort of heroic proportions to write a program that looks good on Windows, the Macintosh, and 10 flavors of UNIX. Java1.0 made the heroic effort, delivering a simple toolkit that mapped common user interface elements to a number of platforms.Unfortunately, the result was a library that, with a lot of work, could give barely acceptable results on different systems. (And there were often different bugs on the different platform graphics implementations.) But it was a start. There are many applications in which portability is more important than user interface slickness, and these applications did benefit from early versions of Java. By now, the user interface toolkit has been completely rewritten so that it no longer relies on the host user interface. The result is far more consistent and, we think, more attractive than in earlier versions of Java.8. InterpretedThe Java interpreter can execute Java bytecodes directly on any machine to which the interpreter has been ported. Since linking is a more incremental and lightweight process, the development process can be much more rapid and exploratory.Incremental linking has advantages, but its benefit for the development process is clearly overstated. In any case, we have found Java development tools to be quite slow. If you are used to the speed of the classic Microsoft Visual C++ environment, you will likely be disappointed with the performance of Java development environments. (The current version of Visual Studio isn't as zippy as the classic environments, however. No matter what languageyou program in, you should definitely ask your boss for a faster computer to run the latest development environments. )9. High PerformanceWhile the performance of interpreted bytecodes is usually more than adequate, there are situations where higher performance is required. The bytecodes can be translated on the fly (at run time) into machine code for the particular CPU the application is running on.If you use an interpreter to execute the bytecodes, "high performance" is not the term that we would use. However, on many platforms, there is also another form ofcompilation, the just-in-time (JIT) compilers. These work by compiling the bytecodes into native code once, caching the results, and then calling them again if needed. This approach speeds up commonly used code tremendously because one has to do the interpretation only once. Although still slightly slower than a true native code compiler, a just-in-time compiler can give you a 10- or even 20-fold speedup for some programs and will almost always be significantly faster than an interpreter. This technology is being improved continuously and may eventually yield results that cannot be matched by traditional compilation systems. For example, a just-in-time compiler can monitor which code is executed frequently and optimize just that code for speed.10. MultithreadedThe enefits of multithreading are better interactive responsiveness and real-time behavior.if you have ever tried to do multithreading in another language, you will be pleasantly surprised at how easy it is in Java. Threads in Java also can take advantage of multiprocessor systems if the base operating system does so. On the downside, thread implementations on the major platforms differ widely, and Java makes no effort to be platform independent in this regard. Only the code for calling multithreading remains the same across machines; Java offloads the implementation of multithreading to the underlying operating system or a thread library. Nonetheless, the ease of multithreading is one of the main reasons why Java is such an appealing language for server-side development.11. DynamicIn a number of ways, Java is a more dynamic language than C or C++. It was designed to adapt to an evolving environment. Libraries can freely add new methods and instance variables without any effect on their clients. In Java, finding out run time type information is straightforward.This is an important feature in those situations in which code needs to be added to a running program. A prime example is code that is downloaded from the Internet to run in a browser. In Java 1.0, finding out runtime type information was anything but straightforward, but current versions of Java give the programmer full insight intoboth the structure and behavior of its objects. This is extremely useful for systems that need to analyze objects at run time, such as Java GUI builders, smart debuggers, pluggable components, and object databases.Java技术介绍Java是一种程序设计平台Java是一种优秀的程序设计语言。
Java编程语言基础(外文文献翻译)(可编辑)
JavaTM Programming Language BasicsLike applications, applets are created from classes. However, applets do not have a main method as an entry point, but instead, have several methods to control specific aspects of applet execution.This lesson converts an application from Lesson 2 to an applet and describes the structure and elements of an applet.1、Application to Applet2、Run the Applet3、Applet Structure and Elements4、Packages5、More Information1、Application to AppletThe following code is the applet equivalent to the LessonTwoB application from Lesson 2. The figure below shows how the running applet looks. The structure and elements of the applet code are discussed after the section on how to run the applet just below.import et;import hics;import r;public class SimpleApplet extends AppletString text "I'm a simple applet";public void inittext "I'm a simple applet";setBackground Color.cyan ;public void startSytln "starting..." ;public void stopSytln "stopping..." ;public void destroySytln "preparing to unload..." ;public void paint Graphics gSytln "Paint" ;g.setColor Color.blue ;g.drawRect 0, 0,getSize .width -1,getSize .height -1 ;g.setColor Color.red ;g.drawString text, 15, 25 ;The SimpleApplet class is declared public so the program that runs the applet a browser or appletviewer , which is not local to the program can access it.2、Run the AppletTo see the applet in action, you need an 6>HTML file with the Applet tag as follows:APPLET CODE SimpleApplet.class WIDTH 200 HEIGHT 100The easiest way to run the applet is with appletviewer shown below where simpleApplet.html is a file that contains the above HTML code:appletviewer simpleApplet.htmlNote: To run an applet written with JavaTM 2 APIs in a browser, the browser must be enabled for the Java 2 Platform. If your browser is not enabled for the Java 2 Platform, you have to use appletviewer to run the applet or install Java Plug-in. Java Plug-in lets you run applets on web pages under the 1.2 version of the Java VM instead of the web browser's default Java VM.3、Applet Structure and ElementsThe Java API Applet class provides what you need to design the appearance and manage the behavior of an applet. This class provides a graphical user interface GUI component called a Panel and a number of methods. To create an applet, you extend or subclass the Applet class and implement the appearance and behavior you want.The applet's appearance is created by drawing onto the Panel or by attaching other GUI components such as push buttons, scrollbars, or text areas to the Panel. The applet's behavior is defined by implementing the methods.3.1 Extending a ClassMost classes of any complexity extend other classes. To extend another class means to write a new class that can use the fields and methods defined in the class being extended. The class being extended is the parent class, and the class doing the extending is the child class. Another way to say this is the child class inherits the fields and methods of its parent or chain of parents. Child classes either call or override inherited methods. This is called single inheritance.The SimpleApplet class extends Applet class, which extends the Panel class, which extends the Container class. The Container class extends Object, which is the parent of all Java API classes. The Applet class provides the init, start, stop, destroy, and paint methods you saw in the example applet. The SimpleApplet class overrides these methods to do what the SimpleApplet class needs them to do. The Applet class provides no functionality for these methods.However, the Applet class does provide functionality for the setBackground method,which is called in the init method. The call to setBackground is an example of calling a method inherited from a parent class in contrast to overriding a method inherited from a parent class.You might wonder why the Java language provides methods without implementations. It is to provide conventions for everyone to use for consistency across Java APIs. If everyone wrote their own method to start an applet, for example, but gave it a different name such as begin or go, the applet code would not be interoperable with other programs and browsers, or portable acrossmultiple platforms. For example, Netscape and Internet Explorer know how to look for the init and start methods.3.2 BehaviorAn applet is controlled by the software that runs it. Usually, the underlying software is a browser, but it can also be appletviewer as you saw in the example. The underlying software controls the applet by calling the methods the applet inherits from the Applet class.The init Method: The init method is called when the applet is first created and loaded by the underlying software. This method performs one-time operations the applet needs for its operation such as creating the user interface or setting the font. In the example, the init method initializes the text string and sets the background color.The start Method: The start method is called when the applet is visited such as when the end user goes to a web page with an applet on it. The example prints a string to the console to tell you the applet is starting. In a more complex applet, the start method would do things required at the start of the applet such as begin animation or play sounds.After the start method executes, the event thread calls the paint method to draw to the applet's Panel. A thread is a single sequential flow of control within the applet, and every applet can run in multiple threads. Applet drawing methods are always called from a dedicated drawing and event-handling thread.The stop and destroy Methods: The stop method stops the applet when the applet is no longer on the screen such as when the end user goes to another web page. The example prints a string to the console to tell you the applet is stopping. In a more complex applet, this method should do things like stop animation or sounds.The destroy method is called when the browser exits. Your applet should implement this method to do final cleanup such as stop live threads.3.3 AppearanceThe Panel provided in the Applet class inherits a paint method from its parent Container class. To draw something onto the Applet's Panel, you implement the paint method to do the drawing. The Graphics object passed to the paint method defines a graphics context for drawing on the Panel. The Graphics object has methods for graphical operations such as setting drawing colors, and drawing graphics, images, and text.The paint method for the SimpleApplet draws the I'm a simple applet string in red inside a blue rectangle.public void paint Graphics gSytln "Paint" ;//Set drawing color to blueg.setColor Color.blue ;//Specify the x, y, width and height for a rectangleg.drawRect 0, 0,getSize .width -1,getSize .height -1 ;//Set drawing color to redg.setColor Color.red ;//Draw the text string at the 15, 25 x-y locationg.drawString text, 15, 25 ;4、PackagesThe applet code also has three import statements at the top. Applications of any size and all applets use import statements to access ready-made Java API classes in packages. This is true whether the Java API classes come in the Java platform download, from a third-party, or are classes you write yourself and store in a directory separate from the program. At compile time, a program uses import statements to locate and reference compiled Java API classes stored in packages elsewhere on the local or networked system. A compiled class in one package can have the same name as a compiled class in another package. The package name differentiates the two classes.The examples in Lessons 1 and 2 did not need a package declaration to call the Sytln Java API class because the System class is in the ng package that is included by default. You never need an import ng.* statement to use the compiled classes in that package.5、More InformationYou can find more information on applets in the Writing Applets trail in The Java Tutorial.文献译文Java 编程语言基础像Java Application小应用程序一样,Java Applet小程序也是从类中创建来的。
计算机专业毕业设计论文外文文献中英文翻译——java对象
1 . Introduction To Objects1.1The progress of abstractionAll programming languages provide abstractions. It can be argued that the complexity of the problems you’re able to solve is directly related to the kind and quality of abstraction。
By “kind” I mean,“What is it that you are abstracting?” Assembly language is a small abstraction of the underlying machine. Many so—called “imperative” languages that followed (such as FORTRAN,BASIC, and C) were abstractions of assembly language。
These languages are big improvements over assembly language,but their primary abstraction still requires you to think in terms of the structure of the computer rather than the structure of the problem you are trying to solve。
The programmer must establish the association between the machine model (in the “solution space,” which is the place where you’re modeling that problem, such as a computer) and the model of the problem that is actually being solved (in the “problem space,” which is the place where the problem exists). The effort required to perform this mapping, and the fact that it is extrinsic to the programming language,produces programs that are difficult to write and expensive to maintain,and as a side effect created the entire “programming methods” industry.The alter native to modeling the machine is to model the problem you’re trying to solve。
Java外文翻译
附件1:外文资料翻译译文图形用户接口一个基本的设计方针是“简单的事情变得容易,困难的事情成为可能。
”劳在Java的图形用户界面(GUI)库原设计目标是允许程序员建立一个GUI ,在所有平台上看起来好。
这一目标没有实现。
相反,Java的罗湖抽象窗口工具包(AWT )产生一个GUI,看着所有系统上同样表现平平。
此外,它是限制性的,你可以用四种字体,你不能访问任何更复杂的GUI 元素,在你的操作系统存在。
也尴尬和非面向对象的Java 1.0 AWT编程模型。
一个学生在我的一个研讨会(曾在Sun公司一直在创造Java的)解释原因:原来的AWT已经构思,设计,并在一个月内实施。
一定的生产力的奇迹,也是为什么设计对象的教训是非常重要的。
Java 1.1 AWT的事件模型,这需要一个更清晰的,面向对象的方法的JavaBeans组件的编程模型是面向可视化编程环境容易创造此外,情况有所好转。
的Java 2(JDK 1.2 ),基本上取代Java基础类(JFC),被称为GUI部分的所有“摇摆完成了转型。
”从旧的Java 1.0 AWT的这是一个易于使用的一整套丰富,易于理解的JavaBeans ,可以拖动和下降(以及手工编程),以建立一个合理的GUI 。
“第三次修订版”的软件产业规则(一个产品是不是良好,直到第三次修订版),似乎与编程语言也是如此。
本章介绍了现代的Java Swing库,使得Swing是Sun公司的最终目的地的GUI库,为Java.2合理的假设,如果你有一些原因,因为你支持旧的代码,你需要使用原有的“老”的AWT (或浏览器的限制),你可以找到介绍,在这本书的第一版在下载。
请注意,一些AWT 组件保持在Java中,并在某些情况下,你必须使用他们。
请注意,这是不是所有的Swing组件或描述类的所有方法的综合词汇。
你在这里看到的是一个简单的介绍。
Swing库是巨大的,本章的目的是只让你的要领和舒适的概念开始。
JAVA的基础外文翻译
外文原文Java FundamentalsThe rise of the Internet and the World Wide Web have fundamentally reshaped computing. Only a few short years ago, the cyber landscape was dominated by stand-alone PCs. Today, nearly all PCs are connected to the Internet. The Internet, itself, was transformed—originally offering a convenient way to share files and information, today it is a vast, distributed computing universe. These changes have been as rapid as they have been profound, and in their wake, they gave rise to a new way to program: Java. Java is the preeminent language of the Internet, but it is more than that. Java has revolutionized programming, changing the way that we think about both the form and the function of a program. To be a professional programmer today implies the ability to program in Java—it has become that important. In the course of this book, you will learn the skills needed to master it. The purpose of this module is to introduce you to Java, including its history, its design philosophy, and several of its most important features. By far, the hardest thing about learning a programming language is the fact that no element exists in isolation. Instead, the components of the language work in conjunction with each other. This interrelatedness is especially pronounced in Java. In fact, it is difficult to discuss one aspect of Java without involving others. To help overcome this problem, this module provides a brief overview of several Java features, including the general form of a Java program, some basic control structures, and operators. It does not go into too many details but, rather, concentrates on the general concepts common to any Java program.1.1 The Origins of JavaComputer language innovation is driven forward by two factors: improvements in the art of programming and changes in the computing environment. Java is no exception. Building upon the rich legacy inherited from C and C++, Java adds refinements and features that reflect the current state of the art in programming. Responding to the rise of the online environment, Java offers features that streamline programming for a highly distributed architecture.Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems in 1991. This language was in itially called “Oak” but was renamed “Java” in 1995. Somewhat surprisingly, the original impetus for Java was not the Internet! Instead, the primary motivation was the need for a platform-independent language that could be used to create software to be embedded in various consumer electronic devices,such as toasters, microwave ovens, and remote controls. As you can probably guess,many different types of CPUs are used as controllers. The trouble was that most computer languages are designed to be compiled for a specific target. For example, consider C++.Although it is possible to compile a C++ program for just about any type of CPU, to do so requires a full C++ compiler targeted for that CPU. The problem, however, is that compilers are expensive and time-consuming to create. In an attempt to find a better solution, Gosling Java Fundamentals and others worked on a portable, cross-platform language that could produce code that would run on a variety of CPUs under differing environments. This effort ultimately led to the creation of Java.About the time that the details of Java were being worked out, a second, and ultimately more important, factor emerged that would play a crucial role in the future of Java. This second force was, of course, the World Wide Web. Had the Web not taken shape at about the same time that Java was being implemented, Java might have remained a useful but obscure language for programming consumer electronics. However, with the emergence of the Web, Java was propelled to the forefront of computer language design, because the Web, too, demanded portable programs.Most programmers learn early in their careers that portable programs are as elusive as they are desirable. While the quest for a way to create efficient, portable (platform-independent)programs is nearly as old as the discipline of programming itself, it had taken a back seat to other, more pressing problems. However, with the advent of the Internet and the Web, the old problem of portability returned with a vengeance. After all, the Internet consists of a diverse,distributed universe populated with many types of computers, operating systems, and CPUs.What was once an irritating but a low-priority problem had become a high-profile necessity.By 1993 it became obvious to members of the Java design team that the problems of portability frequently encountered when creating code for embedded controllers are also found when attempting to create code for the Internet. This realization caused the focus of Java to switch from consumer electronics to Internet programming. So, while it was the desire for an architecture-neutral programming language that provided the initial spark, it was the Internet that ultimately led to Java’s large-scale success.How Java Relates to C and C++Java is directly related to both C and C++. Java inherits its syntax from C. Its object model is adapted from C++. Java’s relationship with C and C++ is important for several reasons. First,many programmers are familiar with the C/C++ syntax. This makes it easy for a C/C++programmer to learn Java and, conversely, for a Java programmer to learn C/C++.Second, Java’s designers did not “reinvent the wheel.” Instead, they further refined analready highly successful programming paradigm. The modern age of programming began with C. It moved to C++, and now to Java. By inheriting and building upon that rich heritage, Java provides a powerful, logically consistent programming environment that takes the best of the past and adds new features required by the online environment. Perhaps most important, because of their similarities, C, C++, and Java define a common, conceptual framework for the professional programmer. Programmers do not face major rifts when switching from one language to another.One of the central design philosophies of both C and C++ is that the programmer is in charge! Java also inherits this philosophy. Except for those constraints imposed by the Internet environment, Java gives you, the programmer, full control. If you program well, your programs reflect it. If you program poorly, your programs reflect that, too. Put differently, Java is not a language with training wheels. It is a language for professional programmers.Java has one other attribute in common with C and C++: it was designed, tested, and refined by real, working programmers. It is a language grounded in the needs and experiences of the people who devised it. There is no better way to produce a top-flight professional programming language.Because of the similarities between Java and C++, especially their support for objectoriented programming, it is tempting to think of Java as simply the “Internet version of C++.”However, to do so would be a mistake. Java has significant practical and philosophical differences.Although Java was influenced by C++, it is not an enhanced version of C++. For example, it is neither upwardly nor downwardly compatible with C++. Of course, the similarities with C++are significant, and if you are a C++ programmer, you will feel right at home with Java.Another point: Java was not designed to replace C++. Java was designed to solve a certain set of problems. C++ was designed to solve a different set of problems. Both will coexist for many years to come.How Java Relates to C#Recently a new language called C# has come on the scene. Created by Microsoft to support its .NET Framework, C# is closely reated to Java. In fact, many of C#’s features were directly adapted from Java. Both Java and C# share the same general C++-style syntax, support distributed programming, and utilize the same object model. There are, of course, differences between Java and C#, but the overall “look and feel” of these languages is very similar. This means that if you already know C#, then learning Java will be especially easy. Conversely, if C# is in your future, then your knowledge of Java will come in handy.Given the similarity between Java and C#, one might naturally ask, “Will C# replace Java?” The answer is No. Java and C# are optimized for two different types of computing environments.Just as C++ and Java will co-exist for a long time to come, so will C# and Java.1.2 Java’s Contribution to the InternetThe Internet helped catapult Java to the forefront of programming, and Java, in turn, has had a profound effect on the Internet. The reason for this is quite simple: Java expands the universe of objects that can move about freely in cyberspace. In a network, there are two very broad categories of objects that are transmitted between the server and your personal computer: passive information and dynamic, active programs. For example, when you read your e-mail, you are viewing passive data. Even when you download a program, the program’s code is still only passive data until you execute it. However, a second type of object can be transmitted to your computer: a dynamic, self-executing program. Such a program is an active agent on the client computer, yet it is initiated by the server. For example, a program might be provided by the server to properly display the data that it is sending.As desirable as dynamic, networked programs are, they also present serious problems in the areas of security and portability. Prior to Java, cyberspace was effectively closed to half of the entities that now live there. As you will see, Java addresses those concerns and, in doing so, has defined a new form of program: the applet.Java Applets and ApplicationsJava can be used to create two types of programs: applications and applets. An application is a program that runs on your computer, under the operating system of that computer. An application created by Java is more or less like one created using any other type of computer language, such as Visual Basic or C++. When used to create applications, Java is not much different from any other computer langua ge. Rather, it is Java’s ability to create applets that makes it important. An applet is an application designed to be transmitted over the Internet and executed by a Java-compatible Web browser. Although any computer language can be used to create an application, only Java can be used to create an applet. The reason is that Java solves two of the thorniest problems associated with applets: security and portability. Before continuing, let’s define what these two terms mean relative to the Internet.SecurityAs you are almost certainly aware, every time you download a “normal” program, you are risking a viral infection. Prior to Java, most users did not download executable programs frequently, and those that did, scanned them for viruses prior to execution. Even so, most users still worried about the possibility of infecting their systems with a virus or allowing a malicious program to run wild in their systems. (A malicious program might gather private information, such as credit card numbers, bank account balances, and passwords by searching the contents of your computer’s local file system.) Java answers these concerns by providinga firewall between a networked application and your computer.When using a Java-compatible web browser, it is possible to safely download Java applets without fear of viral infection. The way that Java achieves this is by confining a Java program to the Java execution environment and not allowing it access to other parts of the computer. (You will see how this is accomplished, shortly.) Frankly, the ability to download applets with confidence that no harm will be done to the client computer is the single most important aspect of Java.PortabilityAs discussed earlier, many types of computers and operating systems are connected to the Internet. For programs to be dynamically downloaded to all of the various types of platforms, some means of generating portable executable code is needed. As you will soon see, the same mechanism that helps ensure security also helps create portability. Indeed, Java’s solution to these two problems is both elegant and efficient.外文翻译JAVA的基础互联网和万维网的崛起已经从根本上重塑了计算。
外文翻译java
外文资料译文及原文JavaJava I/O 系统对编程语言的设计者来说,创建一套好的输入输出(I/O)系统,是一项难度极高的任务。
这一点可以从解决方案的数量之多上看出端倪。
这个问题难就难在它要面对的可能性太多了。
不仅是因为有那么多 I/O 的源和目地(文件,控制台,网络连接等等),而且还有很多方法(顺序的『sequential』,随机的『random-access』, 缓存的『 buffered 』,二进制的『 binary 』,字符方式的『 character 』,行的『by lines 』,字的『 by words 』,等等)。
Java类库的设计者们用"创建很多类"的办法来解决这个问题。
坦率地说Java I/O 系统的类实在是太多了,以至于初看起来会把人吓着(但是,具有讽刺意味的是,这种设计实际上是限制了类的爆炸性增长)。
此外,Java在1.0版之后又对其 I/O 类库作了重大的修改,原先是面向 byte 的,现在又补充了面向Unicode字符的类库。
为了提高性能,完善功能,JDK1.4又加了一个nio(意思是"new I/O"。
这个名字会用上很多年)。
这么以来,如果你想对Java的I/O 类库有个全面了解,并且做到运用自如,你就得先学习大量的类。
此外,了解 I/O 类库的演化的历史也是相当重要的。
可能你的第一反应是 "别拿什么历史来烦我了,告诉我怎么用就可以了! "但问题是,如果你对这段历史一无所知,很快就会被一些有用或是没用的类给搞糊涂了。
本章会介绍 Java 标准类库中的各种 I/O 类,及其使用方法。
File 类在介绍直接从流里读写数据的类之前,我们先介绍一下处理文件和目录的类。
File 类有一个极具欺骗性的名字;或许你会认为这是一个关于文件的类,但它不是。
你可以用它来表示某个文件的名字,也可以用它来表示目录里一组文件的名字。
java-毕业论文外文文献翻译
Advantages of Managed CodeMicrosoft intermediate language shares with Java byte code the idea that it is a low—level language with a simple syntax ,which can be very quickly translated into native machine code。
Having this well-defined universal syntax for code has significant advantages。
Platform independenceFirst,it means that the same file containing byte code instructions can be placed on any platform;at runtime the final stage of compilation can then be easily accomplished so that the code will run on that particular platform. In other words, by compiling to IL we obtain platform independence for 。
NET, in much the same way as compiling to Java byte code gives Java platform independence。
Performance improvementIL is actually a bit more ambitious than Java byte code。
IL is always Just-In—Time compiled (known as JIT),whereas Java byte code was often interpreted。
Java技术外文翻译文献
Java技术外文翻译文献(文档含中英文对照即英文原文和中文翻译)外文:Core Java™ Volume II–Advanced Features When Java technology first appeared on the scene, the excitement was not about a well-crafted programming language but about the possibility of safely executing applets that are delivered over the Internet (see V olume I, Chapter 10 for more information about applets). Obviously, delivering executable applets is practical only when the recipients are sure that the code can't wreak havoc on their machines. For this reason, security was and is a major concern of both the designers and the users of Java technology. This means that unlike other languages andsystems, where security was implemented as an afterthought or a reaction to break-ins, security mechanisms are an integral part of Java technology.Three mechanisms help ensure safety:•Language design features (bounds checking on arrays, no unchecked type conversions, no pointer arithmetic, and so on).•An access control mechanism that controls what the code can do (such as file access, network access, and so on).•Code signing, whereby code authors can use standard cryptographic algorithms to authenticate Java code. Then, the users of the code can determine exactly who created the code and whether the code has been altered after it was signed.Below, you'll see the cryptographic algorithms supplied in the java.security package, which allow for code signing and user authentication.As we said earlier, applets were what started the craze over the Java platform. In practice, people discovered that although they could write animated applets like the famous "nervous text" applet, applets could not do a whole lot of useful stuff in the JDK 1.0 security model. For example, because applets under JDK 1.0 were so closely supervised, they couldn't do much good on a corporate intranet, even though relatively little risk attaches to executing an applet from your company's secure intranet. It quickly became clear to Sun that for applets to become truly useful, it was important for users to be able to assign different levels of security, depending on where the applet originated. If an applet comes from a trusted supplier and it has not been tampered with, the user of that applet can then decide whether to give the applet more privileges.To give more trust to an applet, we need to know two things:•Where did the applet come from?•Was the code corrupted in transit?In the past 50 years, mathematicians and computer scientists have developed sophisticated algorithms for ensuring the integrity of data and for electronic signatures. The java.security package contains implementations of many of these algorithms. Fortunately, you don't need to understand the underlying mathematics to use the algorithms in the java.security package. In the next sections, we show you how message digests can detect changes in data files and how digital signatures can prove the identity of the signer.A message digest is a digital fingerprint of a block of data. For example, the so-called SHA1 (secure hash algorithm #1) condenses any data block, no matter how long, into a sequence of 160 bits (20 bytes). As with real fingerprints, one hopes that no two messages have the same SHA1 fingerprint. Of course, that cannot be true—there are only 2160 SHA1 fingerprints, so there must be some messages with the same fingerprint. But 2160is so large that the probability of duplication occurring is negligible. How negligible? According to James Walsh in True Odds: How Risks Affect Your Everyday Life (Merritt Publishing 1996), the chance that you will die from being struck by lightning is about one in 30,000. Now, think of nine other people, for example, your nine least favorite managers or professors. The chance that you and all of them will die from lightning strikes is higher than that of a forged message having the same SHA1 fingerprint as the original. (Of course, more than ten people, none of whom you are likely to know, will die from lightning strikes. However, we are talking about the far slimmer chance that your particular choice of people will be wiped out.)A message digest has two essential properties:•If one bit or several bits of the data are changed, then the message digest also changes.• A forger who is in possession of a given message cannot construct a fake message that has the same message digest as the original.The second property is again a matter of probabilities, of course. Consider the following message by the billionaire father:"Upon my death, my property shall be divided equally among my children; however, my son George shall receive nothing."That message has an SHA1 fingerprint of2D 8B 35 F3 BF 49 CD B1 94 04 E0 66 21 2B 5E 57 70 49 E1 7EThe distrustful father has deposited the message with one attorney and the fingerprint with another. Now, suppose George can bribe the lawyer holding the message. He wants to change the message so that Bill gets nothing. Of course, that changes the fingerprint to a completely different bit pattern:2A 33 0B 4B B3 FE CC 1C 9D 5C 01 A7 09 51 0B 49 AC 8F 98 92Can George find some other wording that matches the fingerprint? If he had been the proud owner of a billion computers from the time the Earth was formed, each computing a million messages a second, he would not yet have found a message he could substitute.A number of algorithms have been designed to compute these message digests. The two best-known are SHA1, the secure hash algorithm developed by the National Institute of Standards and Technology, and MD5, an algorithm invented by Ronald Rivest of MIT. Both algorithms scramble the bits of a message in ingenious ways. For details about these algorithms, see, for example, Cryptography and Network Security, 4th ed., by William Stallings (Prentice Hall 2005). Note that recently, subtle regularities have been discovered in both algorithms. At this point, most cryptographers recommend avoiding MD5 and using SHA1 until a stronger alternative becomes available.The Java programming language implements both SHA1 and MD5. The MessageDigest class is a factory for creating objects that encapsulate the fingerprinting algorithms. It has a static method, called getInstance, that returns an object of a class that extends the MessageDigest class. This means the MessageDigest class serves double duty:•As a factory class•As the superclass for all message digest algorithmsFor example, here is how you obtain an object that can compute SHA fingerprints:MessageDigest alg = MessageDigest.getInstance("SHA-1");(To get an object that can compute MD5, use the string "MD5" as the argument to getInstance.)After you have obtained a MessageDigest object, you feed it all the bytes in the message by repeatedly calling the update method. For example, the following code passes all bytes in a file to the alg object just created to do the fingerprinting:InputStream in = . . .int ch;while ((ch = in.read()) != -1)alg.update((byte) ch);Alternatively, if you have the bytes in an array, you can update the entire array at once:byte[] bytes = . . .;alg.update(bytes);When you are done, call the digest method. This method pads the input—as required by the fingerprinting algorithm—does the computation, and returns the digest as an array of bytes.byte[] hash = alg.digest();The program in Listing 9-15 computes a message digest, using either SHA or MD5. You can load the data to be digested from a file, or you can type a message in the text area.Message SigningIn the last section, you saw how to compute a message digest, a fingerprint for the original message. If the message is altered, then the fingerprint of the altered message will not match the fingerprint of the original. If the message and its fingerprint are delivered separately, then the recipient can check whether the message has been tampered with. However, if both the message and the fingerprint were intercepted, it is an easy matter to modify the message and then recompute the fingerprint. After all, the message digest algorithms are publicly known, and they don't require secret keys. In that case, the recipient of the forged message and the recomputed fingerprint would never know that the message has been altered. Digital signatures solve this problem.To help you understand how digital signatures work, we explain a few concepts from the field called public key cryptography. Public key cryptography is based on the notion of a public key and private key. The idea is that you tell everyone in the world your public key. However, only you hold the private key, and it is important that you safeguard it and don't release it to anyone else. The keys are matched by mathematical relationships, but the exact nature of these relationships is not important for us.The keys are quite long and complex. For example, here is a matching pair of public and private Digital Signature Algorithm (DSA) keys.Public key:Code View:p:fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f35b91a47e6df 63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17q: 962eddcc369cba8ebb260ee6b6a126d9346e38c5g:678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e35030b71fd7 3da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4y:c0b6e67b4ac098eb1a32c5f8c4c1f0e7e6fb9d832532e27d0bdab9ca2d2a8123ce5a8018b8161 a760480fadd040b927281ddb22cb9bc4df596d7de4d1b977d50Private key:Code View:p:fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f35b91a47e6df 63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17q: 962eddcc369cba8ebb260ee6b6a126d9346e38c5g:678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e35030b71fd73 da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4x: 146c09f881656cc6c51f27ea6c3a91b85ed1d70aIt is believed to be practically impossible to compute one key from the other. That is, even though everyone knows your public key, they can't compute your private key in your lifetime, no matter how many computing resources they have available.It might seem difficult to believe that nobody can compute the private key from the public keys, but nobody has ever found an algorithm to do this for the encryption algorithms that are in common use today. If the keys are sufficiently long, brute force—simply trying all possible keys—would require more computers than can be built from all the atoms in the solar system, crunching away for thousands of years. Of course, it is possible that someone could come up with algorithms for computing keys that are much more clever than brute force. For example, the RSA algorithm (the encryption algorithm invented by Rivest, Shamir, and Adleman) depends on the difficulty of factoring large numbers. For the last 20 years, many of the best mathematicians have tried to come up with good factoring algorithms, but so far with no success. For that reason, most cryptographers believe that keys with a "modulus" of 2,000 bits or more are currently completely safe from any attack. DSA is believed to be similarly secure.Figure 9-12 illustrates how the process works in practice.Suppose Alice wants to send Bob a message, and Bob wants to know this message came from Alice and not an impostor. Alice writes the message and then signs the message digest with her private key. Bob gets a copy of her public key. Bob then applies the public key to verify thesignature. If the verification passes, then Bob can be assured of two facts:•The original message has not been altered.•The message was signed by Alice, the holder of the private key that matches the public key that Bob used for verification.You can see why security for private keys is all-important. If someone steals Alice's private key or if a government can require her to turn it over, then she is in trouble. The thief or a government agent can impersonate her by sending messages, money transfer instructions, and so on, that others will believe came from Alice.The X.509 Certificate FormatTo take advantage of public key cryptography, the public keys must be distributed. One of the most common distribution formats is called X.509. Certificates in the X.509 format are widely used by VeriSign, Microsoft, Netscape, and many other companies, for signing e-mail messages, authenticating program code, and certifying many other kinds of data. The X.509 standard is part of the X.500 series of recommendations for a directory service by the international telephone standards body, the CCITT.The precise structure of X.509 certificates is described in a formal notation, called "abstract syntax notation #1" or ASN.1. Figure 9-13 shows the ASN.1 definition of version 3 of the X.509 format. The exact syntax is not important for us, but, as you can see, ASN.1 gives a precise definition of the structure of a certificate file. The basic encoding rules, or BER, and a variation, called distinguished encoding rules (DER) describe precisely how to save this structure in a binary file. That is, BER and DER describe how to encode integers, character strings, bit strings, and constructs such as SEQUENCE, CHOICE, and OPTIONAL.译文:Java核心技术卷Ⅱ高级特性当Java技术刚刚问世时,令人激动的并不是因为它是一个设计完美的编程语言,而是因为它能够安全地运行通过因特网传播的各种applet。
(完整word版)JAVA外文文献+翻译
Java and the InternetIf Java is, in fact, yet another computer programming language, you may question why it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn't immediately obvious if you’re comin g from a traditional programming perspective. Although Java is very useful for solving traditional stand—alone programming problems, it is also important because it will solve programming problems on the World Wide Web。
1.Client—side programmingThe Web’s in itial server—browser design provided for interactive content, but the interactivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them。
Basic HTML contains simple mechanisms for data gathering: text-entry boxes, check boxes, radio boxes, lists and drop—down lists, as well as a button that can only be programmed to reset the data on the form or “submit” the data on the form back to the server。
java毕业设计外文文献原文及译文
英文文献及中文翻译Thinking in JavaAlthough it is based on C++, Java is more of a “pure” object-oriented language.Both C++ and Java are hybrid languages, but in Java the designers felt that the hybridization was not as important as it was in C++. A hybrid language allows multiple programming styles; the reason C++ is hybrid is to support backward compatibility with the C language. Because C++ is a superset of the C language, it includes many of that language’s undesirable features, which can make some aspects of C++ overly complicated. The Java language assumes that you want to do only object-oriented programming. This means that before you can begin you must shift your mindset into an object-oriented world (unless it’s already there). The benefit of this initial effort is the ability to program in a language that is simpler to learn and to use than many other OOP languages. In this chapter we’ll see the basic components of a Java program and we’ll learn that everything in Java is an object, even a Java program.Each programming language has its own means of manipulating data. Sometimes the programmer must be constantly aware of what type of manipulation is going on. Are you manipulating the object directly, or are you dealing with some kind of indirect representation (a pointer in C or C++) that must be treated with a special syntax?All this is simplified in Java. You treat everything as an object, using a single consistent syntax. Although you treat everything as an object, the identifier you manipulate is actually a “reference” to an object. You might imagine this scene as a television (the object) with your remote control (the reference). As long as you’re holding this reference, you have a connection to the television, but when someone says “change the channel” or “lower the volume,” what you’re manipulating is the reference, which in turn modifies the object. If you want to move around the room and still control the television, you take the remote/reference with you, not the television.Also, the remote control can stand on its own, with no television. That is, just because you have a reference doesn’t mean there’s necessarily an object connected to it. So if you want to hold a word or sentence, you create a String reference:But here you’ve created only the reference, not an object. If you decided to send a message to s at this point, you’ll get an error (at run time) because s isn’t actually attached to anything (there’s no television). A safer practice, then, is always to initialize a reference when you create it.However, this uses a special Java feature: strings can be initialized with quoted text. Normally, you must use a more general type of initialization for objectsWhen you create a reference, you want to connect it with a new object. You do so, in general, with the new keyword. The keyword new says, “Make me a new one of these objects.” So in the preceding example, you can say:Not only does this mean “Make me a new String,” but it also gives information about how to make the String by supplying an initial character string.Of course, String is not the only type that exists. Java comes with a plethora of ready-made types. What’s more important is that you can create your own types. In fact, that’s the fundamental activity in Java programming, and it’s what you’ll be learning about in the rest of this bookIt’s useful to visualize some aspects of how things are laid out while the program is running—in particular how memory is arranged. There are six different places to store data: Registers. This is the fastest storage because it exists in a place different from that of other storage: inside the processor. However, the number of registers is severely limited, so registers are allocated by the compiler according to its needs. You don’t have direct contr ol, nor do you see any evidence in your programs that registers even exist.The stack. This lives in the general random-access memory (RAM) area, but has direct support from the processor via its stack pointer. The stack pointer is moved down to create new memory and moved up to release that memory. This is an extremely fast and efficient way to allocate storage, second only to registers. The Java compiler must know, while it is creating the program, the exact size and lifetime of all the data that is stored on the stack, because it must generate the code to move the stack pointer up and down. This constraint places limits on the flexibility of your programs, so while some Java storage exists on the stack—in particular, object references—Java objects themselves are not placed on the stack. The heap. This is a general-purpose pool of memory (also in the RAM area) where all Java objects live. The nice thing about the heap is that, unlike the stack, the compiler doesn’t needto know how much storage it needs to allocate from the heap or how long that storage must stay on the heap. Thus, there’s a great deal of flexibility in using storage on the heap. Whenever you need to create an object, you simply write the code to create it by using new, and the storage is allocated on the heap when that code is executed. Of course there’s a price you pay for this flexibility. It takes more time to allocate heap storage than it does to allocate stack storage (if you even could create objects on the stack in Java, as you can in C++). Static storage. “Static” is used here in the sense of “in a fixed location” (although it’s also in RAM). Static storage contains data that is available for the entire time a program is running. You can use the static keyword to specify that a particular element of an object is static, but Java objects themselves are never placed in static storage.Constant storage. Constant values are often placed directly in the program code, which is safe since they can never change. Sometimes constants are cordoned off by themselves so that they can be optionally placed in read-only memory (ROM), in embedded systems.Non-RAM storage. If data lives completely outside a program, it can exist while the program is not running, outside the control of the program. The two primary examples of this are streamed objects, in which objects are turned into streams of bytes, generally to be sent to another machine, and persistent objects, in which the objects are placed on disk so they will hold their state even when the program is terminated. The trick with these types of storage is turning the objects into something that can exist on the other medium, and yet can be resurrected into a regular RAM-based object when necessary. Java provides support for lightweight persistence, and future versions of Java might provide more complete solutions for persistenceOne group of types, which you’ll use quite often in your programming, gets special treatment. You can think of these as “primitive” types. The reason for the special trea tment is that to create an object with new—especially a small, simple variable—isn’t very efficient, because new places objects on the heap. For these types Java falls back on the approach taken by C and C++. That is, instead of creating the variable by using new, an “automatic” variable is created that is not a reference. The variable holds the value, and it’s placed on the stack, so it’s much more efficient.Java determines the size of each primitive type. These sizes don’t change from one machine architecture to another as they do in most languages. This size invariance is one reason Java programs are portableJava编程思想“尽管以C++为基础,但Java是一种更纯粹的面向对象程序设计语言”。
JAVA游戏英文文献翻译
J2ME mobile games programmingJ2ME and Wireless DevicesWith the dramatic increase and sophistication of mobile communications devices such as cell phones came demand for applications that can run on those devices. Consumers and corporations want to expand mobile communications devices from voice communications to applications traditionally found on laptops and PCs. They want to send and receive email, store and retrieve personal information, perform sophisticated calculations, and play games.Developers, mobile communications device manufacturers, and mobile network providers are anxious to fill this need, but there is a serious hurdle: mobile communications devices utilize a number of different application platforms and operating systems.Without tweaking the code, an application written for one device cannot run on another device. Mobile communications devices lack a standard application platform and operating system, which has made developing applications for mobile communications devices a risky economic venture for developers.The lack of standards is nothing new to computing or to any developing technology. Traditionally, manufacturers of hardware devices try to corner the market and enforce their own proprietary standard as the de facto standard for the industry. Usually one upstart succeeds, as in the case of Microsoft. Other times, industry leaders form a consortium, such as the Java Community Process Program, to collectively develop a standard. The Wireless Application Protocol (WAP) forum became the initial industry group that set out to create standards for wireless technology. Ericsson, Motorola, Nokia, and Unwired Planet formed theWAP forum in 1997, and it has since grown to include nearly all mobile device manufacturers, mobile network providers, and developers. The WAP forum created mobile communications device standards referred to as theWAP standard. TheWAP standard is an enhancement of HTML, XML, and TCP/IP. One element of this standard is the Wireless Markup Language specification, which consists of a blend of HTML and XML and is used by developers to create documents that can be displayed by a microbrowser. A microbrowser is a diminutive web browser that operateson a mobile communications device.TheWAP standard also includes specifications for aWireless Telephony Application Interface (WTAI) specification and the WMLScript specification. WTAI is used to create an interface for applications that run on a mobile communications device. WMLScript is a stripped-down version of JavaScript.While the WAP forum provided the framework within which developers can build mobile communications device applications, they still had to overcome a common hurdle found in every rapidly developing technology. The sophistication of mobile communications devices, phenomenal growth of the market, and high demand for industrial-strength mobile communications applications out-paced the ability to define and implement new mobile communications device standards.Many sophisticated applications designed for mobile communications devices require the device to process information beyond the capabilities of theWAP specification. J2ME provided the standard to fill this gap. For example, a sales representative wants to check available flights and hotel accommodations, purchase an airline ticket, book the hotel and car rental, and then send the itinerary to a client, all while sitting in a taxi in traffic. The sales representative also wants the itinerary stored on the mobile communications device and retrieved during the trip.J2ME applications referred to as a MIDlet can run on practically any mobile communications device that implements a JVM and MIDP. This encourages developers to invest time and money in building applications for mobile communications devices without the ri sk that the application is device dependent. However, J2ME isn’t seen as a replacement for the WAP specification because both are complementary technologies. Developers whose applications are light-client based continue to use WML and WMLScript. Developers turn to J2ME for heavier clients that require sophisticated processing on the mobile communications device.The Game API PackageThe javax.microedition.lcdui.game package, a welcome addition to MIDP in version 2.0, provides classes that enable developers to build rich gaming content for wireless devices. The classes have been implemented in a way that reduces application size andimproves performance by minimizing the amount of work done by code written in the Java programming language. The API is based on low-level graphics classes such as Graphics and Image from MIDP 1.0, so you can use this package in conjunction with graphics primitives. A good example would be to use the Game API package to render a complex background, and render visual elements on top of it using graphics primitives like drawLine().Note that when methods modify the states of the classes in this package, there is no immediate visible effect. The objects store their states, for use in subsequent calls to paint() – which is fine for gaming applications that redraw the entire screen at the end of every game cycle.The Game API package comprises five classes: GameCanvas is a subclass of javax.microedition.lcdui.Canvas; it provides the basic screen functionality for a game. It includes gaming-oriented methods to query the state of the game keys, and synchronous graphics flushing. Such features simplify building games and improve their performance.Layer is an abstract class that forms the basis for a framework of layered graphics. It represents a visual element in a game, such as a Sprite or a TiledLayer, and has attributes like location, size, and visibility.Sprite is a basic animated layer that can display one of several graphical frames, which are of equal size and are stored in a single Image object. It supports transformations such as flip and rotate, as well as collision-detection methods to simplify implementing the game's logic.TiledLayer represents a visual element composed of a grid of cells that can be filled with a set of tile images. This class enables the developer to create large areas of graphical content without the resource use that a large Image object would require.LayerManager simplifies game development by automating the rendering process. This class is useful for games with multiple layers. It enables the developer to set a view window to represent the user's view of the game, and automatically renders the game's layers to implement the desired view.The Game CanvasThe GameCanvas class is a subclass of javax.microedition.lcdui.Canvas, but differs in two ways: graphics buffering and the ability to query key states. These features of the GameCanvas class offer you enhanced control to deal with events like keystrokes and screen repainting.As I mentioned earlier, you'll get smoother animation if you create graphics objects behind the scenes, in a buffer, then update and repaint the screen simply by invoking paint(getGraphics()) and flushGraphics(). If your graphics are simple, you may not notice much difference if you call repaint() and serviceRepaints() instead, but in games with complex graphics, using the GameCanvas methods will make an appreciable difference.The GameCanvas class makes game programming much easier. You can extend the Canvas class directly to develop your game if you want, but if you do you'll need to implement the Canvas.keyPressed() method, which is called whenever the user presses a button. Errors can arise if the call occurs when multiple threads are doing different things and the code is not properly synchronized. By contrast, if you use GameCanvas you can get the keystroke information whenever you want it, from the getKeyStates() method –and in a more useful form: The keyCode passed to Canvas.keyPressed() gives you information about only a single key, but GameCanvas.getKeyStates() tells you when multiple keys are being pressed simultaneously.The GameCanvas class simplifies game programming in another way. Instead of spreading the logic across multiple methods running on separate threads, as Canvas does, GameCanvas lets you combine all the game functionality in a single loop, under the control of a single thread. Code Sample encloses the game's logic in a single loop: Code Sample : GameCanvas-Based Game Skeletonpublic class MyCanvas extends GameCanvas implements Runnable {public void run() {Graphics g = getGraphics();while(true) {// update the game state// ...int k = getKeyStates();// respond to key eventsflushGraphics();}}}TextBox ClassThe TextBox class is very similar to a TextField class, discussed previously in this chapter.Both are used to receive multiple lines of textual data from a user. You can request that a maximum number of characters be allowed in instances of both the TextBox class and the TextField class. However, the device determines the actual size of both of these instances. Characters that exceed the display area of the screen become scrollable in many devices.The TextBox class and TextField class differ in that the TextBox class is derived from the Screen class, while the TextField class is derived from the Item class. This means that an instance of the Form class cannot contain an instance of the TextBox class, while an instance of a TextField class must be contained within an instance of the Form class.Another important difference between the TextBox class and the TextField class is that the TextBox class uses a CommandListener and cannot use an ItemStateListener. An ItemStateListener is used with an instance of the TextField class, although many times the content of an instance of the TextField class is retrieved and processed when the user selects a command associated with a form that contains the text field.An instance of the TextBox class is created by passing four parameters to the TextBox class constructor. The first parameter is the title of the text box. The second parameter is text used to populate the instance. The third parameter is the maximum number of characters that can be entered into the instance. Keep in mind that this parameter is a request and may not be fulfilled by the device. The device determines the maximum number of characters for an instance of the TextBox class. The last parameter is the constraint used to limit the types of characters that can be placed within the instance.The TextBox class has the same methods as found in the TextField class. Refer tothe “TextField Class” section of this chapter for details on how to use these methods. You’ll also find Te xtBox class methods in the “Quick Reference Guide” section at the end of this chapter.The CanvasAs you’ll recall, each MIDlet has one instance of the Display class, and the Display class has one derived class called the Displayable class. Everything a MIDlet displays on the screen is created by an instance of a class that is derived from the Displayable class. The Display class hierarchy is shown here:public class Displaypublic abstract class Displayablepublic abstract class Screen extends Displayablepublic abstract class Canvas extends Displayablepublic class GraphicsThe Displayable class has two subclasses: Screen and Canvas. The Screen class and its derivatives are used to create high-level components that you learned about in the previous chapter. The Canvas class and its derivatives are used to gain low-level access to the display, which is necessary for graphic- and animation-based applications. Agraphic is used with a canvas.You can think of an instance of the Canvas class as an artist’s can vas on which you draw images that might include text. An instance of the Graphics class is similar to the artist’s tools that are used to draw an image. For example, color, lines, and arcs are some of the graphic tools available to create an image on the canvas. The Canvas class and the Graphics class give you pixel control over everything that appears on the canvas. This low-level control is particularly noticeable whenever text is placed on the canvas because you control every aspect of how characters are formed to display the text.Let’s step back to recall how you display text using the high-level user interface. First, you create an instance of a text field, text box, or string item and then associate text with the instance. Next, the setCurrent() is called and passed the instance (or a container such as a form that contains the instance). You don’t need to be concerned about describing how the device’s application manager is to form each character of the text onthe screen.However, displaying text using the Graphics class requires you to specify the height, width, and other characteristics that describe how each character of the text is to be drawn on the screen. Your application is actually drawing each character as compared to simply specifying the te xt that you want displayed. You’ll learn how to draw characters later in this chapter.A Canvas is created by instantiating a concrete subclass, which is discussed later in this chapter.The Layout of a CanvasThe canvas is divided into a virtual grid in which each cell represents one pixel. Coordinates mark the column and row of a cell within the grid. The x coordinate represents the column, and the y coordinate represents the cell’s row. The first cell located in the upper-left corner of the grid has the coordinate location of 0, 0, where the first zero is the x coordinate and the other zero is the y coordinate.As you probably imagine, the size of the canvas is device dependent since canvas size and the screen size are the same. The screen size of a mobile telephone might be different from the screen size of a PDA, and yet both devices are capable of running the same MIDlet. Your MIDlet should determine the canvas size of the device that implements your graphic application before drawing on the screen. The canvas size is measured in pixels. Your MIDlet should determine the canvas size of the deviceThe paint() and repaint() MethodsYou don’t call the paint() method directly. Instead, the paint() method is called automatically by the setCurrent() method when the MIDlet is started. You call the repaint() whenever the canvas or a portion of the canvas must be refreshed.Let’s say that you want to draw text on a canvas that is already displayed on the screen. First, you create the text using a graphic, whic h you’ll learn how to do later inthis chapter. Next, you call the repaint() method to have the entire canvas redrawn, which includes text and images that currently exist on the screen and the new text, unless you’veremoved existing text or images.There are two versions of the repaint() method. One version requires no parameters and repaints the entire canvas. The other version requires four parameters that definethe region of the canvas that is to be repainted. The first two parameters are the x andy coordinates for the upper-left corner of the region, and the last two parameters arethe width and height of the region.You specify a region of the canvas to repaint whenever only a portion of the canvas has changed and when you don’t want to waste time re painting the entire canvas, such as when an animated image is displayed on the screen.This is known as clipping. Animation is the illusion of movement caused by rapidly changing images on the screen, where each image is slightly different from the previous image. Each image displayed on the screen is referred to as a frame. A key to successful animation is speed. You must change frames in such a way that users don’t notice the change. Typically, a small portion of a frame changes in an animated image. The repaint() method is capable of repainting only the portion of the frame that changed rather than the entire frame, which dramatically reduces the time that is necessary to change a frame on the screen.The serviceRepaints() method is another painting met hod that you’ll use when developing a low-level user interface for your application. Apaint request is one of many requests a MIDlet can make to the application manager of a small computing device. Other requests can be made to store data or to communicate with a remote computer. Sometimes outstanding requests can be given a higher process priority by the device’s application manager than a paint request. However, you’ll need to override outstanding requests to have the canvas repainted whenever an image is being animated; otherwise, a delay in repainting the canvas destroys the effect of animation.The serviceRepaints() method directs the device’s application manager to override outstanding requests for service with the repaint request. The repaint request becomes the next request to be processed by the application manager.showNotify() and hideNotify()The device’s application manager calls the showNotify() method immediately before theapplication manager displays the canvas. You define the showNotify() method with statements that prepare the canvas for display, such as initializing resources by beginning threads or assigning values to variables as required by your application.The hideNotify() method is called by the application manager after the canvas is removed from the screen. You define the hideNotify() method with statements that free resources that were allocated when the showNotify() method was called. This includes deactivating threads and resetting values assigned to variables as necessary.GraphicsAs you recall from earlier in this chapter, the screen of the low-level user interface is a canvas, which is an instance of the Canvas class. The canvas is organized into a grid in which each cell of the grid is a pixel. Coordinates, as explained in the previous sections, identify each cell. An image is drawn on the canvas by using a virtual graphical device called a graphic context, such as the rectangle and line. A graphic context is an instance of the Graphics class. You’ll learn about these virtu al graphical devices in this section.Reference to the graphic context is passed to the paint() method. A mutable image, as you’ll remember, is an image that can be altered by your MIDlet. You’ve seen how to create a graphic context in previous listings that defined the paint() method. Reference to the graphic context passed to a paint() method exists for the duration of the paint() method. Once the MIDlet leaves the paint() method, the graphic context goes out of scope.The graphic context can no longer be used to draw on the canvas, even if reference to the graphic context is retained. In contrast, a graphic context created in association with a mutable image remains available to the MIDlet as long as reference to the image and the image itself remains in s cope. You’ll learn how to create a graphic context using a mutable image later in this chapter.。
Java编程语言基础(外文文献翻译)(可编辑)
JavaTM Programming Language BasicsLike applications, applets are created from classes. However, applets do not have a main method as an entry point, but instead, have several methods to control specific aspects of applet execution.This lesson converts an application from Lesson 2 to an applet and describes the structure and elements of an applet.1、Application to Applet2、Run the Applet3、Applet Structure and Elements4、Packages5、More Information1、Application to AppletThe following code is the applet equivalent to the LessonTwoB application from Lesson 2. The figure below shows how the running applet looks. The structure and elements of the applet code are discussed after the section on how to run the applet just below.import et;import hics;import r;public class SimpleApplet extends AppletString text "I'm a simple applet";public void inittext "I'm a simple applet";setBackground Color.cyan ;public void startSytln "starting..." ;public void stopSytln "stopping..." ;public void destroySytln "preparing to unload..." ;public void paint Graphics gSytln "Paint" ;g.setColor Color.blue ;g.drawRect 0, 0,getSize .width -1,getSize .height -1 ;g.setColor Color.red ;g.drawString text, 15, 25 ;The SimpleApplet class is declared public so the program that runs the applet a browser or appletviewer , which is not local to the program can access it.2、Run the AppletTo see the applet in action, you need an 6>HTML file with the Applet tag as follows:APPLET CODE SimpleApplet.class WIDTH 200 HEIGHT 100The easiest way to run the applet is with appletviewer shown below where simpleApplet.html is a file that contains the above HTML code:appletviewer simpleApplet.htmlNote: To run an applet written with JavaTM 2 APIs in a browser, the browser must be enabled for the Java 2 Platform. If your browser is not enabled for the Java 2 Platform, you have to use appletviewer to run the applet or install Java Plug-in. Java Plug-in lets you run applets on web pages under the 1.2 version of the Java VM instead of the web browser's default Java VM.3、Applet Structure and ElementsThe Java API Applet class provides what you need to design the appearance and manage the behavior of an applet. This class provides a graphical user interface GUI component called a Panel and a number of methods. To create an applet, you extend or subclass the Applet class and implement the appearance and behavior you want.The applet's appearance is created by drawing onto the Panel or by attaching other GUI components such as push buttons, scrollbars, or text areas to the Panel. The applet's behavior is defined by implementing the methods.3.1 Extending a ClassMost classes of any complexity extend other classes. To extend another class means to write a new class that can use the fields and methods defined in the class being extended. The class being extended is the parent class, and the class doing the extending is the child class. Another way to say this is the child class inherits the fields and methods of its parent or chain of parents. Child classes either call or override inherited methods. This is called single inheritance.The SimpleApplet class extends Applet class, which extends the Panel class, which extends the Container class. The Container class extends Object, which is the parent of all Java API classes. The Applet class provides the init, start, stop, destroy, and paint methods you saw in the example applet. The SimpleApplet class overrides these methods to do what the SimpleApplet class needs them to do. The Applet class provides no functionality for these methods.However, the Applet class does provide functionality for the setBackground method,which is called in the init method. The call to setBackground is an example of calling a method inherited from a parent class in contrast to overriding a method inherited from a parent class.You might wonder why the Java language provides methods without implementations. It is to provide conventions for everyone to use for consistency across Java APIs. If everyone wrote their own method to start an applet, for example, but gave it a different name such as begin or go, the applet code would not be interoperable with other programs and browsers, or portable acrossmultiple platforms. For example, Netscape and Internet Explorer know how to look for the init and start methods.3.2 BehaviorAn applet is controlled by the software that runs it. Usually, the underlying software is a browser, but it can also be appletviewer as you saw in the example. The underlying software controls the applet by calling the methods the applet inherits from the Applet class.The init Method: The init method is called when the applet is first created and loaded by the underlying software. This method performs one-time operations the applet needs for its operation such as creating the user interface or setting the font. In the example, the init method initializes the text string and sets the background color.The start Method: The start method is called when the applet is visited such as when the end user goes to a web page with an applet on it. The example prints a string to the console to tell you the applet is starting. In a more complex applet, the start method would do things required at the start of the applet such as begin animation or play sounds.After the start method executes, the event thread calls the paint method to draw to the applet's Panel. A thread is a single sequential flow of control within the applet, and every applet can run in multiple threads. Applet drawing methods are always called from a dedicated drawing and event-handling thread.The stop and destroy Methods: The stop method stops the applet when the applet is no longer on the screen such as when the end user goes to another web page. The example prints a string to the console to tell you the applet is stopping. In a more complex applet, this method should do things like stop animation or sounds.The destroy method is called when the browser exits. Your applet should implement this method to do final cleanup such as stop live threads.3.3 AppearanceThe Panel provided in the Applet class inherits a paint method from its parent Container class. To draw something onto the Applet's Panel, you implement the paint method to do the drawing. The Graphics object passed to the paint method defines a graphics context for drawing on the Panel. The Graphics object has methods for graphical operations such as setting drawing colors, and drawing graphics, images, and text.The paint method for the SimpleApplet draws the I'm a simple applet string in red inside a blue rectangle.public void paint Graphics gSytln "Paint" ;//Set drawing color to blueg.setColor Color.blue ;//Specify the x, y, width and height for a rectangleg.drawRect 0, 0,getSize .width -1,getSize .height -1 ;//Set drawing color to redg.setColor Color.red ;//Draw the text string at the 15, 25 x-y locationg.drawString text, 15, 25 ;4、PackagesThe applet code also has three import statements at the top. Applications of any size and all applets use import statements to access ready-made Java API classes in packages. This is true whether the Java API classes come in the Java platform download, from a third-party, or are classes you write yourself and store in a directory separate from the program. At compile time, a program uses import statements to locate and reference compiled Java API classes stored in packages elsewhere on the local or networked system. A compiled class in one package can have the same name as a compiled class in another package. The package name differentiates the two classes.The examples in Lessons 1 and 2 did not need a package declaration to call the Sytln Java API class because the System class is in the ng package that is included by default. You never need an import ng.* statement to use the compiled classes in that package.5、More InformationYou can find more information on applets in the Writing Applets trail in The Java Tutorial.文献译文Java 编程语言基础像Java Application小应用程序一样,Java Applet小程序也是从类中创建来的。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
*** 学院毕业设计(论文)外文资料翻译系(院):计算机工程学院专业:计算机科学与技术(软件技术)姓名:***学号:***外文出处:The Programmer(用外文写)附件: 1.外文资料翻译译文;2.外文原文。
注:请将该封面与附件装订成册。
附件1:外文资料翻译译文JSP技术概述JSP的优点JSP页面最终会转换成servler。
因而,从根本上,JSP页面能够执行的任何任务都可以用servler来完成。
然而,这种底层的等同性并不意味着servler 和JSP页面对于所有的情况都等同适用。
问题不在于技术的能力,而是二者在便利性、生产率和可维护性上的不同。
毕竟,在特定平台上能够用Java编程语言完成的事情,同样可以用汇编语言来完成,但是选择哪种语言依旧十分重要。
和单独使用servler相比,JSP提供下述好处:(1)JSP中HTML的编写与维护更为简单。
JSP中可以使用常规的HTML:没有额外的反斜杠,没有额外的双引号,也没有暗含的Java语法。
(2)能够使用标准的网站开发工具。
即使对那些对JSP一无所知的HTML 工具,我们也可以使用,因为它们会忽略JSP标签(JSP tags)。
(3)可以对开发团队进行划分。
Java程序员可以致力于动态代码。
Web 开发人员可以将经理集中在表示层(presentation layer)上。
对于大型的项目,这种划分极为重要。
依据开发团队的大小,及项目的复杂程度,可以对静态HTML和动态内容进行弱分离(weaker separation)和强分离(stronger separation)。
在此,这个讨论并不是让您停止使用servlets,只使用JSP。
几乎所有的项目都会同时用到这两种技术。
针对项目中的某些请求,您可能会在MVC构架下组合使用这两项技术。
我们总是希望用适当的工具完成相对应的工作,仅仅是servlet并不能填满您的工具箱。
JSP相对于竞争技术的优势许多年前,Marty受到邀请,参加一个有关软件技术的小型(20个人)研讨会.做在Marty旁边的人是James Gosling--- Java编程语言的发明者。
隔几个位置,是来自华盛顿一家大型软件公司的高级经理。
在讨论过程中,研讨会的主席提出了Jini的议题,这在当时是一项新的Java技术.主席向该经理询问他的想法.他继续说,他们会持续关注这项技术,如果这项技术变得流行起来,他们会遵循公司的“接受并扩充(embrace and extend)”的策略.此时, Gosling随意地插话说“你的意思其实就是不接受且不扩充(disgrace and distend)。
”在此, Gosling的抱怨显示出,他感到这个公司会从其他公司那里拿走技术,用于他们自己的目的.但你猜这次怎么样?这次鞋子穿在了另一只脚上。
Java社团没有发明这一思想----将页面设计成由静态HTML和用特殊标签标记的动态代码混合组成.。
ColdFusion 多年前就已经这样做了。
甚至ASP(来自于前述经理所在公司的一项产品)都在JSP出现之前推广了这种方式。
实际上,JSP不只采用了这种通用概念,它甚至使用许多和ASP相同的特殊标签。
因此,问题变成:为什么使用JSP,而不使用其他技术呢?我们的第一反应是我们不是在争论所有的人应该做什么。
其他这些技术中,有一些也很不错,在某些情况下也的确是合情合理的选择.然而,在其他情形中,JSP明显要更好一些。
下面给出几个理由。
与.NET和Active Server Pages (ASP)相比.NET是Microsoft精心设计的一项技术。
是与servlets和JSP直接竞争的技术。
JSP的优势体现在两个方面。
首先,JSP可以移植到多种操作系统和Web服务器,您不必仅仅局限于部署在Windows 和IIS上尽管核心.NET平台可以在好几种非Windows平台上运行,但ASP这一部分不可以。
您不能期望可以将重要的应用部署到多种服务器和操作系统。
对于某些应用,这种差异没有什么影响。
但有些应用,这种差异却非常重要。
其次,对于某些应用,底层语言的选择至关重要。
例如,尽管.NET的C#语言设计优良,且和Java类似,但熟悉核心C#语法和众多工具库的程序员很少。
此外,许多开发者依旧使用最初版本的ASP。
相对于这个版本,JSP在动态代码方面拥有明显的优势。
使用JSP,动态部分是用Java编写的,而非VBScript过其他ASP专有的语言,因此JSP更为强劲,更适合于要求组件重用的复杂应用。
当将JSP与之前版本的ColdFusion对比时,您可能会得到相同的结论。
应用JSP,您可以使用Java编写“真正的代码”,不必依赖于特定的服务器产品。
然而,当前版本的ColdFusion满足J2EE服务器的环境,允许开发者容易的混合使用ColdFusion和Servlet/JSP代码。
与PHP相比PHP(“PHP:Hypertext Preprocessor”的递归字母缩写词)是免费的、开放源代码的、HTML嵌入其中的脚本语言,与ASP和JSP都有某种程度的类似。
JSP的一项优势是动态部分用Java编写,而Java已经在联网、数据库访问、分布式对象等方面拥有广泛的API,而PHP需要学习全新的、应用相对广泛的语言。
JSP的第二项优势是,和PHP相比,JSP拥有极为广泛的工具和服务器提供商的支持。
与纯Servlet相比原则上,JSP并没有提供Servlet不能完成的功能。
实际上,JSP文档在后台被自动转换成Servlet。
但是编写(和修改)常规的HTML,要比无数println 语句生成HTML要方便得多。
另外,通过将表示与内容分离,可以为不同的人分配不同的任务:网页设计人员使用熟悉的工具构建HTML,要么为Servlet 程序员留出空间插入动态内容,要么通过XML标签间接调用动态内容。
这是否表示您只可以学习JSP,将Servlet丢到一边呢?当然不是!由于以下4种原因,JSP开发人员需要了解Servlet:(1)JSP页面会转换成Servlet。
不了解Servlet就无法知道JSP如何工作。
(2)JSP由静态HTML、专用的JSP标签和Java代码组成。
哪种类型的Java代码呢?当然是Servlet代码!如果不了解Servlet编程,那么就无法编写这种代码。
(3)一些任务用Servlet完成比用JSP来完成要好。
JSP擅长生成由大量组织有序的结构化HTML或其他字符数据组成的页面。
Servlet擅长生成二进制数据,构建结构多样的页面,以及执行输出很少或者没有输出的任务(比如重定向)。
(4)有些任务更适合于组合使用Servlet和JSP来完成,而非单独使用Servlet或JSP。
与JavaScript相比JavaScript和Java编程语言完全是两码事,前者一般用于在客户端动态生成HTML,在浏览器载入文档时构建网页的部分内容。
这是一项有用的功能,一般与JSP的功能(只在服务器端运行)并不发生重叠。
和常规HTML页面一样,JSP页面依旧可以包括用于JavaScript的SCRIPT标签。
实际上,JSP甚至能够用来动态生成发送到客户端的JavaScript。
因此,JavaScript不是一项竞争技术,它是一项补充技术。
JavaScript也可以用在服务器端,最因人注意的是SUN ONE(以前的iPlanet)、IIS和BroadVision服务器。
然而,Java更为强大灵活、可靠且可移植。
与WebMacro和Velocity相比JSP决非完美。
许多人都曾指出过JSP中能够改进的功能。
这是一件好事,JSP的优势之一是该规范由许多不同公司组成的社团控制。
因此,在后续版本中,这项技术能够得到协调的改进。
但是,一些组织已经开发出了基于Java的替代技术,试图弥补这些不足。
据我们的判断,这样做是错误的。
使用扩充JSP和Servlet技术的第三方工具,如Apache Structs,是一种很好的思路,只要该工具带来的好处能够补偿工具带来的额外复杂性。
但是,试图使用非标准的工具代替JSP则不理想。
在选择一项技术时,需要权衡许多方面的因素:标准化、可移植性、集成性、行业支持和技术特性。
对于JSP替代技术的争论几乎只是集中在技术特性上,而可移植性、标准化和集成性也十分重要。
例如,Servlet和JSP规范为Web应用定义了一个标准的目录结构,并提供用于部署Web应用的标准文件(.war文件)。
所有JSP兼容的服务器必须支持这些标准。
我们可以建立过滤器作用到任意树木的Servlet和JSP页面上,但不能用于非标准资源。
Web应用安全设置也同样如此。
此外,业界对JSP和Servlet技术的巨大支持使得这两项技术都有了巨大的进步,从而减轻了对JSP的许多批评。
例如,JSP标准标签库和JSP 2.0表达式语言解决了两种最广泛的批评:缺乏良好的迭代结构;不使用显式的Java代码或冗长的jsp:useBean元素难以访问动态结果。
三、对JSP的误解忘记JSP技术是服务器端技术下面是Marty收到的一些典型问题(大部分问题不止一次的出现)。
•我们的服务器正在运行JDK1.4。
我如何将Swing组件用到JSP页面中呢?我如何将图像放到JSP页面中?我不知道读取图像文件应该使用哪些Java I/O命令。
Tomcat不支持JavaScript,当用户在图像上移动鼠标时,我如何使图像突出显示呢?•我们的客户使用不理解JSP的旧浏览器。
我应该怎么做?当我们的客户在浏览器中使用“ViewλSource”(查看源代码)时,如何阻止他们看到JSP标签?所有这些问题都基于浏览器对服务器端的过程在有所了解的假定之上。
但事实上浏览器并不了解服务器端的过程。
因此:•如果要将使用Swing组件的applet放到网页中,重要的是浏览器的Java 版本,和服务器的Java版本无关。
如果浏览器支持Java 2平台,您可以使用正常的APPLET(或Java插件)标签,即使在服务器上使用了非Java技术也须如此。
您不需要JavaλI/O来读取图像文件,您只需将图像放在存储Web资源的目录中(即WEB-INF/classes向上两级的目录),并输出一个正常的IMG标签。
•您应该用SCRIPT标签,使用客户端JavaScript创建在鼠标下会更改的图像,这不会由于服务器使用JSP而改变。
•浏览器根本不“支持”JSP----它们看到的只是JSP页面的输出。
因此,如同对待静态HTML页面一样,只需确保JSP输出的HTML与浏览器兼容。
•当然,您不需要采取什么措施来阻止客户看到JSP标签,这些标签在服务器上进行处理,发送给客户的输出中并不出现。
混淆转换期间和请求期间JSP页面需要转换成servlet。