Manish Seminar Report

download Manish Seminar Report

of 18

Transcript of Manish Seminar Report

  • 8/2/2019 Manish Seminar Report

    1/18

    ASEMINAR REPORT

    ON

    JAVA APPLETSIn partial fulfillment of requirements for the degree of

    Bachelor of TechnologyIn

    Computer Science & EngineeringSUBMITTED BY:

    Manish Jain

    DEPARTMENT OF COMPUTER SCIENCE & ENGG.RAJ KUMAR GOEL INSTITUTE OF TECHNOLOGY

    GHAZIABAD

  • 8/2/2019 Manish Seminar Report

    2/18

    CERTIFICATE

    This is to certify that the Seminar entitled JAVAAPPLETS

    Submitted byMANISH JAIN under my guidancein partial fulfillment of the degree of B.Tech inComputer Science & Engineering ofU.P.TechnicalUniversity, Lucknowduring the academic year 2010-

    2011(6th

    SEM).

    Date: 18/04/20111Place: Ghaziabad

    Head, Computer Science DepS.K.Gaur

  • 8/2/2019 Manish Seminar Report

    3/18

    ACKNOWLEDGEMENT

    It gives me immense pleasure in presenting seminar on the topic

    JAVA APPLETS. I acknowledge the enormous assistance and

    excellent co-operation extended to by my respected guide Mr.

    Manish Gupta.

    I would also like to thank the staff members for their

    valuable support. Lastly I would like to express my heartfelt

    indebtedness towards all those who have helped me directly or

    indirectly for the success of the seminar.

    Manish Jain

  • 8/2/2019 Manish Seminar Report

    4/18

    Table of Contents

    ABSTRACT CONCEPT TECHNICAL INFORMATION SIMILAR TECHNOLOGIES EMBEDDING IN WEB PAGE EXAMPLE UNSIGNED APPLETS SIGNED APPLETS ADVANTAGES DISADVANTAGES ALTERNATIVES CONCLUSION RECOMMENDATION REFERENCES

  • 8/2/2019 Manish Seminar Report

    5/18

    1.ABSTRACT

    Web design has moved to the next level with theintroduction of java technology in the computing andprogramming industry. This introduction has made atremendous impact in the capabilities andfunctionalities of web pages. Now using not only HTMLcodes but java scripts and java applets, moreinteractivities and functionalities can be added to webpages. This seminar paper looks at what a java applet is,how to write applet codes and how to deploy them onweb pages.

  • 8/2/2019 Manish Seminar Report

    6/18

    Java Applet-Concept

    Java Applet is an applet delivered to the users in the form ofJava bytecode.Java applets can run in aWeb browserusing aJava Virtual Machine(JVM), or inSun'sAppletViewer, a stand-alone tool for testing applets.

    Java applets were introduced in the first version of the Java language in1995. Java applets are usually written in theJava programming languagebut they can also be written in other languages that compile to Javabytecode such asJython,[8]JRuby,[9] orEiffel(viaSmartEiffel).[10]

    Java applets run at a speed that is comparable to (but generally slowerthan) other compiled languages such asC++, but many times faster than

    JavaScript.[11] In addition they can use 3Dhardware acceleration that isavailable from Java. This makes applets well suited for non trivial,computation intensive visualizations.

    Since Java'sbytecode isplatform independent, Java applets can beexecuted by browsers for many platforms, includingMicrosoft Windows,Unix,Mac OSandLinux. It is also trivial to run a Java applet as anapplication with very little extra code. This has the advantage of runninga Java applet in offline mode without the need for any Internet browsersoftware and also directly from the developmentIDE.

    http://en.wikipedia.org/wiki/Java_bytecodehttp://en.wikipedia.org/wiki/Java_bytecodehttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Java_Virtual_Machinehttp://en.wikipedia.org/wiki/Java_Virtual_Machinehttp://en.wikipedia.org/wiki/Sun_Microsystemshttp://en.wikipedia.org/wiki/Sun_Microsystemshttp://en.wikipedia.org/wiki/Sun_Microsystemshttp://en.wikipedia.org/wiki/AppletViewerhttp://en.wikipedia.org/wiki/AppletViewerhttp://en.wikipedia.org/wiki/Java_%28programming_language%29http://en.wikipedia.org/wiki/Java_%28programming_language%29http://en.wikipedia.org/wiki/Jythonhttp://en.wikipedia.org/wiki/Jythonhttp://en.wikipedia.org/wiki/Java_applet#cite_note-7http://en.wikipedia.org/wiki/Java_applet#cite_note-7http://en.wikipedia.org/wiki/JRubyhttp://en.wikipedia.org/wiki/JRubyhttp://en.wikipedia.org/wiki/Java_applet#cite_note-8http://en.wikipedia.org/wiki/Java_applet#cite_note-8http://en.wikipedia.org/wiki/Eiffel_%28programming_language%29http://en.wikipedia.org/wiki/Eiffel_%28programming_language%29http://en.wikipedia.org/wiki/SmartEiffelhttp://en.wikipedia.org/wiki/SmartEiffelhttp://en.wikipedia.org/wiki/Java_applet#cite_note-9http://en.wikipedia.org/wiki/Java_applet#cite_note-9http://en.wikipedia.org/wiki/C%2B%2Bhttp://en.wikipedia.org/wiki/C%2B%2Bhttp://en.wikipedia.org/wiki/C%2B%2Bhttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Java_applet#cite_note-10http://en.wikipedia.org/wiki/Java_applet#cite_note-10http://en.wikipedia.org/wiki/Hardware_accelerationhttp://en.wikipedia.org/wiki/Hardware_accelerationhttp://en.wikipedia.org/wiki/Bytecodehttp://en.wikipedia.org/wiki/Bytecodehttp://en.wikipedia.org/wiki/Cross-platformhttp://en.wikipedia.org/wiki/Cross-platformhttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Mac_OShttp://en.wikipedia.org/wiki/Mac_OShttp://en.wikipedia.org/wiki/Mac_OShttp://en.wikipedia.org/wiki/Linuxhttp://en.wikipedia.org/wiki/Linuxhttp://en.wikipedia.org/wiki/Linuxhttp://en.wikipedia.org/wiki/Integrated_development_environmenthttp://en.wikipedia.org/wiki/Integrated_development_environmenthttp://en.wikipedia.org/wiki/Integrated_development_environmenthttp://en.wikipedia.org/wiki/Linuxhttp://en.wikipedia.org/wiki/Mac_OShttp://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Cross-platformhttp://en.wikipedia.org/wiki/Bytecodehttp://en.wikipedia.org/wiki/Hardware_accelerationhttp://en.wikipedia.org/wiki/Java_applet#cite_note-10http://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/C%2B%2Bhttp://en.wikipedia.org/wiki/Java_applet#cite_note-9http://en.wikipedia.org/wiki/SmartEiffelhttp://en.wikipedia.org/wiki/Eiffel_%28programming_language%29http://en.wikipedia.org/wiki/Java_applet#cite_note-8http://en.wikipedia.org/wiki/JRubyhttp://en.wikipedia.org/wiki/Java_applet#cite_note-7http://en.wikipedia.org/wiki/Jythonhttp://en.wikipedia.org/wiki/Java_%28programming_language%29http://en.wikipedia.org/wiki/AppletViewerhttp://en.wikipedia.org/wiki/Sun_Microsystemshttp://en.wikipedia.org/wiki/Java_Virtual_Machinehttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Java_bytecode
  • 8/2/2019 Manish Seminar Report

    7/18

    Java applet that was created as supplementary demonstrationmaterial for a scientific publication.[

    http://en.wikipedia.org/wiki/Java_applet#cite_note-0http://en.wikipedia.org/wiki/Java_applet#cite_note-0http://en.wikipedia.org/wiki/Java_applet#cite_note-0http://en.wikipedia.org/wiki/Java_applet#cite_note-0
  • 8/2/2019 Manish Seminar Report

    8/18

    Technical information

    Java applets are executed in a ''[[sandbox (security)|sandbox]]'' by mostweb browsers, preventing them from accessing local data like[[Clipboard (software)|clipboard]] or [[file system]]. The code of theapplet is downloaded from a [[web server]] and the browser either[[Compound document|embeds]] the applet into a web page or opens anew window showing the applet's [[user interface]].

    A Java applet extends the class{{Javadoc:SE|package=java.applet|java/applet|Applet}}, or in the case ofa [[Swing (Java)|Swing]] applet,{{Javadoc:SE|package=javax.swing|javax/swing|JApplet}}. The classmust override methods from the applet class to set up a user interfaceinside itself (Applet is a descendant of{{Javadoc:SE|java/awt|Panel}} which is a descendant of{{Javadoc:SE|java/awt|Container}}. As applet inherits from container, ithas largely the same user interface possibilities as an ordinary Java

    application, including regions with user specific visualization.

    The first implementations involved downloading an applet class by class.While classes are small files, there are frequently a lot of them, soapplets got a reputation as slow loading components. However, since[[JAR (file format)|jar]]s were introduced, an applet is usually deliveredas a single file that has a size of the bigger image (hundreds of kilobytesto several megabytes).

    The [[Domain Name System|domain]] from where the applet executablehas been downloaded is the only domain to which the usual (unsigned)applet is allowed to communicate. This domain can be different from thedomain where the surrounding HTML document is hosted.

  • 8/2/2019 Manish Seminar Report

    9/18

    Java [[Static library|system libraries]] and [[Runtime library|runtimes]]are backwards compatible, allowing to write code that runs both oncurrent and on future versions of the Java virtual machine.

    Similar technologies

    Many Java developers, blogs and magazines are recommending that

    the [[Java Web Start]] technology be used in place ofApplets.[http://www.javaworld.com/javaworld/jw-07-2001/jw-0706-webstart.htmlJavaWorld.com][http://javachannel.net/wiki/pmwiki.php/FAQ/Applets JavaChannel.net]

    A [[Java Servlet]] is sometimes informally compared to be "like" aserver-side applet, but it is different in its language, functions, and ineach of the characteristics described here about applets.

  • 8/2/2019 Manish Seminar Report

    10/18

    Embedding into web page

    The applet can be displayed on the web page by making use of thedeprecated [[HTML element#Images andobjects|applet]] HTMLelement,[http://www.w3.org/TR/html401/struct/objects.html#edef-APPLET W3.org] or the recommended objectelement.[http://www.w3.org/TR/html401/struct/objects.html#edef-OBJECT W3.org] A non standard embedelement can be used with Mozilla family browsers.This specifies the applet's source and location. Object

    and embed tags can also download and install Javavirtual machine (if required) or at least lead to the plugin page.Applet and object tags also supportloading of the serialized applets that start in some particular (ratherthan initial) state. Tags also specify the message that shows up in placeof the applet if the browser cannot run it due any reason.

    However, despite object being officially arecommended tag, as of 2010, the support of the objecttag was not yet consistent among browsers and Sun keptrecommending the older applet tag for deploying inmultibrowser environments,[http://download.java.net/jdk7/docs/technotes/guides/plugin/developer_guide/using_tags.html#object Sun's position on appletand object tags] as it remained the only tag consistentlysupported by the most popular browsers. To support multiple

    browsers, the object tag currently requires JavaScript(that recognizes the browser and adjusts the tag), usage of additionalbrowser-specific tags or delivering adapted output from the serverside. Deprecating applet tag has beencriticised.[http://mindprod.com/jgloss/applet.html#OBJECTCriticism] of APPLET tag deprecation Oracle now provides a

  • 8/2/2019 Manish Seminar Report

    11/18

    maintained JavaScript code[http://www.java.com/js/deployJava.txt Java applet launcher fromOracle] to launch applets with cross platform workarounds.

    ExampleThe following example is made simple enough to illustrate the essential use of Javaapplets through its java.applet package. It also uses classes from the Java [[AbstractWindow Toolkit]] (AWT) for producing actual output (in this case, the "[[Helloworld program|Hello, world!]]" message).

    import java.applet.Applet;

    import java.awt.*;

    // Applet code for the "Hello, world!" example.

    // This should be saved in a file named as "HelloWorld.java".

    public class HelloWorld extends Applet {

    // This method is mandatory, but can be empty (i.e., have no actual code).

    public void init() { }

    // This method is mandatory, but can be empty.(i.e.,have no actual code).

    public void stop() { }

    // Print a message on the screen (x=20, y=10).

    public void paint(Graphics g) {

    g.drawString("Hello, world!", 20,10);

  • 8/2/2019 Manish Seminar Report

    12/18

    // Draws a circle on the screen (x=40, y=30).

    g.drawArc(40,30,20,20,0,360);

    }

    }

    Additional simple applets are available atWikiversity.[http://en.wikiversity.org/wiki/Java_applets Java applet section inWikiversity]

    For [[compiler|compilation]], this code is saved on a plain-[[ASCII]] file with thesame name as the class and .java extension, i.e. HelloWorld.java.The resulting HelloWorld.class applet should be placed on the web serverand is invoked within an [[HTML]] page by using an oran tag. For example:

    HelloWorld_example.html

    A Java applet example

    Here it is:

  • 8/2/2019 Manish Seminar Report

    13/18

    This is where HelloWorld.class runs.

    Displaying the HelloWorld_example.html page from a Web server, theresult should look as this:

    '''A Java applet example'''

    Here it is: Hello, world!

    To minimize download time, applets are usually delivered in a form of compressed[[ZIP (file format)|zip]] archive (having [[JAR (file format)|jar]] extension). If allneeded classes (only one in our case) are placed in compressed archive''example.jar'', the embedding code would look different:

    Here it is:

    This is where HelloWorld.class runs.

    Applet inclusion is described in detail in Sun's official page about the APPLETtag.[http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html Java.Sun.com] Sun's APPLET tag page

  • 8/2/2019 Manish Seminar Report

    14/18

    Sufficient running speed is also utilized in applets for playing non trivial computer

    games like chess

  • 8/2/2019 Manish Seminar Report

    15/18

    Unsigned Applets

    Limitations for the unsigned applets are understood as"draconian":[http://www.wutka.com/hackingjava/ch3.htm Java Security FAQApplet Security Restrictions] by Mark Wutka they have no access to the localfilesystem and web access limited to the applet download site; there are also manyother important restrictions. For instance, they cannot access system properties,use their own [[class loader]], call [[native code]], execute external commands on alocal system or redefine classes belonging to core packages included as part of aJava release. While they can run in a standalone frame, such frame contains a

    header, indicating that this is an untrusted applet. Successful initial call of theforbidden method does not automatically create a security hole as an accesscontroller checks the entire [[Call stack|stack]] of the calling code to be sure thecall is not coming from an improper location.

    As with any complex system, multiple security problems have been discovered andfixed since Java was first released. Some of these (like the Calendar serializationsecuritybug[http://slightlyrandombrokenthoughts.blogspot.com/2008/12/calendar-

    bug.html Description of Calendar serialization security bug]) persisted formany years without anybody being aware. However it seems that most (if not all)security holes are closed before anybody being able to exploit them in a largerscale.

    Some studies mention applets crashing the browser or overusing [[Centralprocessing unit|CPU]] resources but these are classified as nuisances and not as true security flaws. However, unsigned applets may be

    involved in combined attacks that exploit a combination of multiple severeconfiguration errors in other parts of thesystem.[http://avirubin.com/block.java.pdf Avirubin.com] An unsignedapplet can also be more dangerous to run directly on the server where it is hostedbecause while code base allows it to talk with the server, running inside it canbypass the firewall. An applet may also try [[Denial-of-service attack|DoS attacks]]on the server where it is hosted but usually people who manage the web site alsomanage the applet, making this unreasonable. Communities may solve this

  • 8/2/2019 Manish Seminar Report

    16/18

    problem via [[Code review|source code review]] or running applets on a dedicateddomain.[http://strategy.wikimedia.org/wiki/Proposal:Java_applet_supportStrategy.Wikimedia.org], proposal with discussion about Java applets incommunity sites[http://Ultrastudio.org Ultrastudio.org], user editableeducational site with full applet support

    The unsigned applet can also try to download malware hosted on originatingserver. However it could only store such file into temporary folder (as its transientdata) and has no means to complete the attack by executing it. There wereattempts to use applets for spreading Phoenix and Siberia exploits thisway{{citation needed|date=October 2010}}, while these exploits do not use Javainternally and were also distributed in a number of other ways.

    As of 1999 no real security breaches involving unsigned applets have ever beenpublicly reported.[http://www.cs.princeton.edu/sip/faq/java-faq.php3 Java Security FAQ][http://www.securingjava.com/chapter-four/ ~ G.McGraw, E.W. Felten. Securing Java. ISBN 047131952X] Using anup-to-date Web browser is usually enough to be safe against the known directattacks from unsigned applets.

    SIGNED APPLETS

    They do not have the security restrictions imposed on unsigned ones and can runoutside the security sandbox.NOTE: When a signed applet is accessed from a java Script code in an HTML page,the applet is executed within the sandbox. This implies that signed appletsessentially behaves like unsigned applets.

  • 8/2/2019 Manish Seminar Report

    17/18

    ADVANTAGES

    Automatically integrated with HTML; hence, resolved virtually allinstallation issues.

    Can be accessed from various platforms and various java-enabled webbrowsers.

    Can provide dynamic, graphics capabilities and visualizations Implemented in Java, an easy-to-learn OO programming language

    DISADVANTAGES

    Applets cant find anyinformation about the local computer They are quite slow. They need JVM enabled Browser to execute them. Stability depends on stability of the clients web server Performance directly depend on clients machine

    Alternatives

    Alternative technologies exist (for example, [[JavaScript]], [[Curl(programming language)|Curl]], [[Adobe Flash|Flash]], and [[MicrosoftSilverlight]]) that satisfy some of the scope of what is possible with an

    applet. Of these, JavaScript is not always viewed as a competingreplacement; JavaScript can coexist with applets in the same page, assist inlaunching applets (for instance, in a separate frame or providing platformworkarounds) and later be called from the appletcode.[http://www.rgagnon.com/javadetails/java-0170.htmlRgagnon.com], calling a Java applet from JavaScript [[JavaFX]] that isan extension of Java platform may also be viewed as an alternative.

  • 8/2/2019 Manish Seminar Report

    18/18

    Conclusion

    Having strategically discussed java applets, its development, deployment,

    advantages and disadvantages, it can be seen that writing java applet codes arevery simple to do as well as can add functionality and interactivity to your webpages.

    RECOMMENDATIONS

    When designing a web page that you need that some logical applications run on,using java applet is more convenient. Finally, when designing a java applet, bear inmind that there are some fractions of people that will not view your applet, alsobefore allowing an applet to run on your browser, make sure that you know andtrust its source or that it is signed.

    References

    1. Deitel (2007):Java How to Program Seventh Edition, Pearson Education, Inc.USA2. John.R.Hubbard, Phd (2004):Programming with java Second Edition.TheMcGraw-Hill Companies, Inc. USA.3, Lesson: Applet (The Java Tutorials>Deployment).http://java.sun.com/doc/books/tutorial/deployment/applet/.