欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > PPT文档下载
    分享到微信 分享到微博 分享到QQ空间

    Java Tutorial - Spring 2000Part 1- Introduction to Java .ppt

    • 资源ID:372957       资源大小:135.50KB        全文页数:43页
    • 资源格式: PPT        下载积分:2000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要2000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Java Tutorial - Spring 2000Part 1- Introduction to Java .ppt

    1、njmnpac.syr.edu,1,Java Tutorial - Spring 2000 Part 1: Introduction to Java Language and Applets,http:/www.npac.syr.edu/projects/tutorials/Java/ Instructors: Geoffrey Fox , Nancy McCracken Syracuse University 111 College Place Syracuse New York 13244-4100,njmnpac.syr.edu,2,Abstract of Java Tutorial,P

    2、art 1: Overview including History of Java Development Overall Java Philosophy and Features including security etc. Part 2: Java Programming Language Object Oriented and Class Structure Exceptions Part 3: Applet Programming and Threads Abstract Windowing Toolkit Part 4: Networking and I/O Multithread

    3、ing,njmnpac.syr.edu,3,What is Java in a NutShell?,What is Java? A simple, object oriented, distributed, interpreted, robust, safe, architecture neutral, portable, high performance, multithreaded, dynamic language. Java is interesting because It is both a general purpose object-oriented language alon

    4、g the lines of C+ and it is particularly designed to interface with Web pages and to enable distributed applications over the internet. The Web is becoming the dominant software development arena; this will drive Java as the best supported, most widely taught language Particularly good as a language

    5、 for K-12 teaching Even outside the web, e.g. in scientific computing, Java is as good and in some (modest) respects better than all other languages,njmnpac.syr.edu,4,Java is an important language in the world,The Java Language has several good design features secure, safe (wrt bugs), object-oriente

    6、d, familiar (to C C+ and even Fortran programmers) Java has a very good set of libraries covering everything from commerce, multimedia, images to math functions (under development at http:/math.nist.gov/javanumerics) Java has best available electronic and paper training and support resources, growin

    7、g labor force trained in Java Java is rapidly getting best integrated program development environments Java naturally integrated with network and universal machine supports powerful “write once-run anywhere” model,njmnpac.syr.edu,5,Java is also important in computer science,Increasingly, Java is the

    8、 language used for important computing paradigms that support applications: object-oriented computing, event-driven computing, distributed objects, linkage to databases, visual/component computing, client/servers, networking, multimedia computing . . . So Java is an important language to include at

    9、an advanced computer science level, along with other languages such as C+, that are useful to students to get jobs. But the good design features of Java also make it suitable for teaching basic computer science concepts: algorithms, data structures, software design, . . . See the (old, but still rel

    10、evant) discussion by Doug Lea at http:/gee.cs.oswego.edu/dl/html/javaInCS.html,njmnpac.syr.edu,6,Architecture of Java Applets,Browsers (HotJava, Netscape 2.0/3.0/4.0, Microsoft IE .) supporting Java allow arbitrarily sophisticated dynamic multimedia applications inserts called Applets, written in Ja

    11、va, to be embedded in the regular HTML pages and activated on each exposure of a given page.,web server,Java codeis compiled to produceapplet codes, part of web document collection,web client, running browser such as Netscape or IE,executes (restricted) applet code to display in browser window,Inter

    12、net,njmnpac.syr.edu,7,Architecture of Java Applications,Java applications are compiled and run on a machine just like any other general programming language such as C/C+. No web server or network are required although Java applications may also use network connections for distributed computing.,Java

    13、 codeis compiled to producebytecodesrun by Java interpreter to produce results,OR Java codeis compiled to producenative coderun directly on machine for better performance,njmnpac.syr.edu,8,Java Applications in a Nutshell,All Java programs are written into a file with a “.java“ extension. Application

    14、s are .java files with a main method which is excuted first. How to compile and run a Java application (via bytecodes): Run the compiler on a .java file: javac MyProgram.javaproducing a file “MyProgram.class“ of Java bytecodes Run the interpreter on a .class file: java MyProgramwhich executes the by

    15、tecodes The resources javac and java are part of JDK and are not in Netscape and so are not necessarily available on the same machine as your web server.,njmnpac.syr.edu,9,The Simplest Java Application: Hello,World!,Since Java is object-oriented, programs are organized into modules called classes, w

    16、hich may have data in variables and subroutines called methods.,class HelloWorld public static void main (String args) System.out.println(“Hello World!”); ,Each program is enclosed in a class definition.,main() is the first method that is run.,The notation class.method or package.class.method is how

    17、 to refer to a public method (with some exceptions).,Syntax is similar to C - braces for blocks, semicolon after each statement. One difference: upper and lower case matter!,njmnpac.syr.edu,10,Java Applets,Java applets are classes written in Java which are intended not to run as stand-alone programs

    18、 (as applications do) but as subprograms of a browser which is already managing a window. Applets should NOT have a main method but rather init, start, paint etc. for displaying on the browser window Applets are not trusted as a default, so they have several restrictions on running on the client mac

    19、hine no printing or file I/O cannot connect through the network to any machine but its own server any new windows created by the applet have a warning label,njmnpac.syr.edu,11,Preparing an Applet,The applet should be run through javac compiler getting a .class file as before: javac MyApplet.java The

    20、 resulting file MyApplet.class is then stored in the document collection of a web server (hence has a URL location). Also create an HTML file (say MyApplet.html) with an applet tag to MyApplet.class.When the browser loads the .html file, it will also download the .class file and invoke the java inte

    21、rpreter to run the init, start, and paint methods.,njmnpac.syr.edu,12,The Simplest Java Applet: Hello, World!,Java applets are part of the class hierarchy that can call methods to display on a screen (within the browser window). One way to draw on the screen is to call the method drawString from the

    22、 standard method paint.,import java.awt.Graphics;public class HelloApplet extends java.applet.Applet public void paint (Graphics g) g.drawString(“Hello World!”, 5, 25); ,The import statement (similar to an include) allows the use of methods from the Graphics class .,The paint method displays a graph

    23、ics object on the screen - one of the standard methods that takes the place of main for applets.,Puts this as a subclass of Applet.,njmnpac.syr.edu,13,Displaying your applet from a Web page.,You should name the file with your applet name, HelloWorldApplet.java, run the compiler (javac), getting a by

    24、tecode file HelloWorldApplet.class, which you put in a web directory., Simple Hello PageMy Java applet says:,Name of your applet class.,The browser will use a rectangle of width 150 pixels and height 25 pixels to display the applet within the other html.,njmnpac.syr.edu,14,More Details on Applet Tag

    25、s - I,Given the following HTMLRuns the “StockGraph.class“ executable as an applet. WIDTH and HEIGHT are attributes that are passed along to the applet. If the optional CODEBASE attribute is provided, then load the executable image from the directory specified by CODEBASE. Without the CODEBASE attrib

    26、ute, will look for StockGraph.class in the local servers hierarchy (relative to where the HTML was loaded), otherwise look for StockGraph.class on the given http hierarchy. May also supply an ARCHIVE attribute which specifies a “.jar” file to download (akin to tar on UNIX). The class named in the CO

    27、DE attribute should be one of the classes in the jar file. Tag and attribute names are case insensitive.,njmnpac.syr.edu,15,More Details on Applet Tags - II, Put a bunch of text here to be displayed by browsers such as Netscape 2.0 on Windows 3.1 that do not support JavaALT specifies text to display

    28、ed if the browser understands the applet tag, but if unable to run applets. NAME specifies the name of this instance of the applet; This will make it possible for applets on the same page to find and communicate with each other. ALIGN specifies the alignment of the applet. The possible values are th

    29、e same as those available in the IMG tag (top, middle, bottom, texttop, absmiddle, baseline, absbottom, left, right). Align=top which aligns top of applet with top of tallest item in the line Align=texttop which aligns top of applet with top of the tallest text in the line VSPACE and HSPACE specifie

    30、s the vertical and horizontal spacing in pixels, around the applet space.,njmnpac.syr.edu,16, Tags and Applets,The applet tag can be followed by parameters:.The Java program accesses this information byString attribute;attribute = getParameter(“attributename1“);if( attribute = null ) attribute = you

    31、rdefaultvalue; / null is Java way of saying unset Typically this processing would be in init() method of Applet,njmnpac.syr.edu,17,Java vs. JavaScript,Despite the word “java” in the name, JavaScript is a different language than Java, albeit with some similarities. A JavaScript program is written dir

    32、ectly into the HTML page, and is executed by the JavaScript intrepeter, so also executes dynamic web page content in the browser window. JavaScript is special purpose - it is an object-based language that deals directly with browser entities such as windows, textfields, forms, frames and documents.

    33、JavaScript can respond to browser events (not as many as Javas more complex capabilities with the user interface) such as mouse clicks and user-typed text. JavaScript is easy and fast to write, but not as powerful as Java.,njmnpac.syr.edu,18,Multi-tier Architecture,Distributed applications on the we

    34、b naturally have a multi-tier architecture. Java plays a role at all three levels: Graphical User Interface and client side analysis systems, including visualization Middle layer servers and software integration, including web servers, distributed object servers and other application servers. Less i

    35、mportant for backend client software, which may be legacy code.,Middle level servers,Client user interface running through browser,Internet,Internet or proprietary network,Backend computing or databases,njmnpac.syr.edu,19,Overview and History of Java Development,njmnpac.syr.edu,20,History of Java La

    36、nguage and Team,Starts in 1991 by Project Green - a group in Sun that detaches from the main campus as a semi-autonomous task force focused on operating software for consumer electronic devices such as smart set-top boxes Gosling (creator of Sun NeWS which had major conceptual impact both on current

    37、 Java and Telescript models) realizes that C+ is not adequate and initiates development of a new language Oak, later renamed as Java. A PDA (Personal Digital Assistant - codename *7) based on Oak/Java ready in 1993. Green Team incorporates as FirstPerson, Inc. *7 proposal to Time-Warner rejected in

    38、1993. 3DO deal falls through in 1994. FirstPerson, Inc. dissolves. Small group (30 people, now Java Team) continues development and decides to adapt Oak as a Web technology.,njmnpac.syr.edu,21,History of Java Language and Team until Dec. 95,An experimental web browser written in Java, called WebRunn

    39、er and later renamed as HotJava, ready in 1994. Alpha release of Java and browser HotJava April 95. Netscape licences Java in May 95 and builds Java into Netscape 2.0 - This confuses ownership and open-ness of Java Beta JDK (Java Development Kit) published in summer/fall 95. It is better software bu

    40、t lower functionality than Alpha. First alpha Java books appear in fall 95 such as a popular overview by SAMS and technical book “Java!“ by Tim Ritchey, edited by New Riders. Dec 4 1995 Business Week cover story on “Software Revolution - The Web Changes Everything“ exposes Java as a breakthrough for

    41、ce in the expanding Web/Internet. Also points out that “Java as a business“ is yet to be defined. In next week, SGI IBM Adobe Macromedia and finally Microsoft adopt/license Java. Java goes into open standards process and is adopted by Web community.,njmnpac.syr.edu,22,More Recent Java History,1996 J

    42、avaOne Developers Conference (now held annually in June) focused on applets. Attendance of 5000 people. 1997 JavaOne focused on JavaBeans and new version of the language JDK1.1, both designed to put Java in line with other developments in component and secure distributed web object computing and use

    43、 of databases. 1998 JavaOne featured attendance of 14,000+ and focused on Enterprise JavaBeans and other Enterprise classes, developing more on server-side applications. 1999 JavaOne had over 20,000 attendees. Continued development of JINI for dynamic networking, embedded devices such as Palm Pilots

    44、.,njmnpac.syr.edu,23,Overall Java Philosophy and Features,njmnpac.syr.edu,24,Some Key Java Features,First we discuss original Java base language features as discussed in Java: A White Paper by Sun Microsystems - October 1995 draft by James Gosling and Henry McGilton - enumerates the original design

    45、of Java: Simple and Familiar Object-oriented Architecture-neutral Portable Somewhat Interpreted Distributed Robust Secure High performance Multi Threaded Dynamic Finally we mention additional features added to Java in more recent versions.,njmnpac.syr.edu,25,Java Features - Its Simple and Familiar!,

    46、Java omits several rarely used, poorly understood and confusing features of C+ including operator overloading, multiple inheritance, pointers and automatic type coercions. It adds automatic garbage collection which makes dynamic programming easier in Java than in C or C+. No more mallocs! It also ad

    47、ds Interface construct, similar to Objective C concept, which often compensates for the lack of multiple inheritance by allowing method calling syntax to be “inherited“. The resulting language is familiar as it looks like C+ but is simpler and hence easier to program in. It also results in a much sm

    48、aller kernel which is suitable for planned Java ports to consumer electronic devices. Base (alpha) interpreter is 40Kb, libraries and threads add additional 175Kb.,njmnpac.syr.edu,26,Java Features - Its Object-oriented,Java model can be viewed as a C+ subset, with some dynamic elements inherited fro

    49、m Objective-C (method overloading, garbage collection). Structures, Unions and Functions are absorbed into data and methods of Java classes - Java is Simple! The strength of Java object-oriented model is not is sophistication but in simplicity and the extensive class library associated with the syst

    50、em (some 250 public classes were released in both alpha and beta). Java class plays also a role of a communication atom in the Web embedding model. Applet classes identify themselves by names in the HTML applet tag. Applet downloads other classes, present in the applet source. Hence, the Java class names play the role of addressing mode for the distributed Java code database.,


    注意事项

    本文(Java Tutorial - Spring 2000Part 1- Introduction to Java .ppt)为本站会员(lawfemale396)主动上传,麦多课文档分享仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文档分享(点击联系客服),我们立即给予删除!




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1 

    收起
    展开