{"id":1991,"date":"2017-05-12T15:31:00","date_gmt":"2017-05-12T15:31:00","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=1991"},"modified":"2024-11-16T14:56:39","modified_gmt":"2024-11-16T14:56:39","slug":"java-applets-are-depricated","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/java-applets-are-depricated\/","title":{"rendered":"Java Applets are deprecated"},"content":{"rendered":"<h3>Overview<\/h3>\r\n<p>In the olden days, applets are the way to embed java code into web browsers. Java applets are deprecated since Java 9.\u00a0<span class=\"ui_qtext_rendered_qtext\">However, in these modern days, we have efficient alternatives for Java Applets.<\/span><\/p>\r\n<p>Java applets are special Java programs that were developed to run embedded Java code in Web pages. An applet is launched from the web document HTML code. To develop an applet we need to extend the Applet class.\u00a0<\/p>\r\n<h3>\u00a0<\/h3>\r\n<h3>Java Listing<\/h3>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package applets;\r\n\r\nimport java.applet.Applet;\r\nimport java.awt.Graphics;\r\n\r\n@SuppressWarnings(\"deprecation\")\r\npublic class HelloApplet extends Applet {\r\n\r\n  public void paint(Graphics g) {\r\n    g.drawString(\"Hello from www.TestingDocs.com\", 25, 25);\r\n  }\r\n}\r\n<\/pre>\r\n<p>Try the run the applet <strong>Right click &gt;&gt; Run As &gt;&gt; Java Applet . <\/strong><\/p>\r\n<p>We would get the following error.<\/p>\r\n<h3>Error<\/h3>\r\n<p>Error: Could not find or load main class sun.applet.AppletViewer<br \/>Caused by: java.lang.ClassNotFoundException: sun.applet.AppletViewer<\/p>\r\n<h3>Screenshot:<\/h3>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1993 size-full\" title=\"Java Applets are deprecated\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Applets-Depricated.png\" alt=\"Java Applets are deprecated\" width=\"1920\" height=\"1025\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Applets-Depricated.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Applets-Depricated-300x160.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Applets-Depricated-1024x547.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Applets-Depricated-768x410.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-Applets-Depricated-1536x820.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>An <strong>AppletViewer<\/strong> is a java program that executes java applets that are embedded in web pages.<\/p>\r\n<h3>Java Applet Alternatives<\/h3>\r\n<p><span class=\"ui_qtext_rendered_qtext\">Since, Java Applets are deprecated we will look at some alternatives to run Java code in a web browser.<\/span><\/p>\r\n<p><span class=\"ui_qtext_rendered_qtext\"><strong>Java Web Start<\/strong> is a good alternative for java applets. <\/span><\/p>\r\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/deployment\/webstart\/\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.oracle.com\/javase\/tutorial\/deployment\/webstart\/<\/a><\/p>\r\n<p><span class=\"ui_qtext_rendered_qtext\">Server socket programming etc. <\/span><span class=\"ui_qtext_rendered_qtext\">Other Web Technologies, for example HTML 5 is a good alternative to Java Applets.<\/span><\/p>\r\n<p>For Enterprise needs <strong>Servlets\/JSP<\/strong> and <strong>EJBs<\/strong> are way more powerful way to run dynamic Java code on Web Containers like Tomcat, JBoss, WebLogic etc.\u00a0\u00a0<\/p>\r\n<p>&#8212;<\/p>\r\n<p>Java Tutorial on this website: <strong><a href=\"https:\/\/www.testingdocs.com\/java-tutorial\/\">https:\/\/www.testingdocs.com\/java-tutorial\/<\/a><\/strong><\/p>\r\n<p>For more information on Java, visit the official website :<\/p>\r\n<p><strong><a href=\"https:\/\/www.oracle.com\/in\/java\/\" rel=\"noopener\">https:\/\/www.oracle.com\/in\/java\/<\/a><\/strong><\/p>\r\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-1991\" data-postid=\"1991\" class=\"themify_builder_content themify_builder_content-1991 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Overview In the olden days, applets are the way to embed java code into web browsers. Java applets are deprecated since Java 9.\u00a0However, in these modern days, we have efficient alternatives for Java Applets. Java applets are special Java programs that were developed to run embedded Java code in Web pages. An applet is launched [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-1991","post","type-post","status-publish","format-standard","hentry","category-java-programs","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=1991"}],"version-history":[{"count":9,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1991\/revisions"}],"predecessor-version":[{"id":21070,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1991\/revisions\/21070"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=1991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=1991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=1991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}