Applet
Applet is a legacy Java technology for embedding and presenting dynamic/interactive code & interface components into HTML rendered by a browser, achieving one of the earliest RIA stacks. The term Applet is most commonly used to describe technology originally released by Sun for the Java programming language, designed to run in an end-user's browser client.
Contents
Specifications
- W3C -- HTML 4.0 spec - section on Applets .vs. Object/Embed: https://www.w3.org/TR/REC-html40/struct/objects.html#h-13.4
AWT
- JDK 1.8 -- AWT (JAVADOCS): https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html
[2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
Java Applet
The method below shows how to embed an Applet on an HTML page using the deployJava JavaScript helper utility from Sun Microsystems/Oracle, which was during the peak of their lifetime, the recommended way of interacting with and using applets (along with traditional fallbacks to the straight Object/Embed and Applet custom tag methods, for browsers with JavaScript and/or embedded objects disabled or otherwise unavailable):
<script src="http://java.com/js/deployJava.js"></script> <script> var attributes = {codebase:'http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D', code:'java2d.Java2DemoApplet.class', archive:'Java2Demo.jar', width:710, height:540} ; var parameters = {fontSize:16} ; var version = '1.6' ; deployJava.runApplet(attributes, parameters, version); </script> <noscript> <object type="application/x-java-applet;version=1.5.0" codebase="http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D" width="710" height="540"> <param name="archive" value="Java2Demo.jar" /> <param name="code" value="java2d.Java2DemoApplet.class" /> <param name="backgroundcolor" value="FFFFFF" /> <embed type="application/x-java-applet;version=1.5.0" codebase="http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D" archive="Java2Demo.jar" code="java2d.Java2DemoApplet.class" width="710" height="540"> <noembed> <applet archive="Java2Demo.jar" code="java2d.Java2DemoApplet.class" width="710" height="540"> <param name="backgroundcolor" value="FFFFFF" /> </applet> </noembed> </embed> </object> </noscript>
Deprecated simple method (no longer works in many modern browsers):
<applet width=300 height=300 code="MyCoolApplet.class"> <param name="background" value="FFFFFF"></param> <param name="shadowcolor" value="FFFFFF"></param> ... <img src="MyCoolApplet.jpg" title="You need to enable Java to see this applet." /> </applet>
The above code basically says you have an Applet that you want to display with a width of 300 (pixels) and height of 300 (pixels), and with a Java class that generates the applet named "MyCoolApplet" (where MyCoolApplet.java is some Java code which has already been compiled into MyCoolApplet.class. It also accepts some parameters as specified by the <param> tag, which represent a name and value pair; for example "background" for the color of this applet's background, in this case set to FFFFFF or white (notice it does not use the opening "#" as in "#FFFFFF" hash to represent the color value as a hexadecimal number as CSS and HTML styles use). (NOTE: you can not, however, use the MyCoolApplet.java code directly in the applet, this will result in a rendering error and either the fallback image of the applet within the <applet> tags, or the default empty applet window, or nothing, depending on the browser.)
EXAMPLES
- Some example homecooked Java applets: http://richardbowles.tripod.com/java/menu.htm
- THE Java Applet tutorial (with examples): http://www.realapplets.com/tutorial/
- JlGUI - Winamp cloned as a Java applet: http://www.javazoom.net/applets/jlguiapplet/jlguiapplet.html[14]
- 3D Cube Applet: http://www.javafile.com/imagefx/cube3d/cube3d.php
- Ping Pong applet: http://javaboutique.internet.com/PingPong/[15][16][17][18]
- 3d earth rotation: http://www.coderanch.com/t/436595/GUI/java/earth-rotation
- JustSlides – a Java slide show applet: http://ian.goldby.net/justslides/
- Jmol: http://jmol.sourceforge.net/ | DEMO (an open-source Java viewer for chemical structures in 3D)
Tools
- Live Video Recording - Java Applet SDK: http://vimas.com/video.php
Resources
- Java Sun Applets: http://java.sun.com/applets/
- deployJava.js: https://www.java.com/js/deployJava.txt (JavaScript reference wrapper for embedding Applets via Object-Embed-Applet tags, Swing/JavaFX via JNLP)
- JavaTM Applet Reference: http://www.duckware.com/applets/reference.html
- The Quintessential Applet: http://www.exampledepot.com/egs/java.applet/BasicApplet.html
- How to use java.net.URLConnection to fire and handle HTTP requests?: http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests
- Java / JavaScript Socket Bridge: http://stephengware.com/proj/javasocketbridge/[19][20]
- A TCP socket bridge for Javascript: http://blog.wolfman.com/articles/2009/9/12/a-tcp-socket-bridge-for-javascript
- Java 2D API Overview: http://docs.oracle.com/javase/8/docs/technotes/guides/2d/spec/j2d-intro.html#wp62980
- Java MP4 Player Applet: http://www.ibm.com/developerworks/java/library/j-mpeg4/
- Java MPEG Player: http://peace.snu.ac.kr/dhkim/java/MPEG/
Tutorials
- Oracle -- Java 8 - Applet Development Guide: http://docs.oracle.com/javase/8/docs/technotes/guides/deploy/applet_dev_guide.html#JSDPG1032 (includes section on migrating to JavaWebStart)
- Lesson - Java Applets: http://download.oracle.com/javase/tutorial/deployment/applet/
- How to Make Applets: http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/applet.html
- How to Write a Simple Applet: https://home.cs.colorado.edu/~main/applets/Simple.html
- Java Applet tutorial: http://profs.logti.etsmtl.ca/mmcguffin/learn/java/
- Applet basics: http://www.tutorialspoint.com/java/java_applet_basics.htm
- Reverse Engineering Java Applets - Basic Level (reverse engineer the infamous 3D-cube Applet): http://social-hackers.blogspot.com/2011/06/reverse-engineering-java-applets-basic.html
- Integrating an Applet in a Web Application: https://netbeans.org/kb/docs/web/applets.html[22]
- Displaying applet in JSP (jsp:plugin action tag): https://www.javatpoint.com/displaying-applet-in-jsp
- Step by Step Instructions for Creating Your First Applet in NetBeans 7.2: http://www.ccs.neu.edu/course/is4300f12/netbeans1.htm
- How to resize Java applet to fit browser's window: https://www.codejava.net/java-se/applet/resizing-java-applet-to-fit-browsers-window[23][24]
- Migrating From Applets to Java Desktop Apps in JavaFX: https://www.slideshare.net/brunoborges/migrating-from-applets-to-java-desktop-apps-in-javafx/
- Bringing Swing to the Web: https://today.java.net/pub/a/today/2006/04/20/bringing-swing-to-the-web.html
- Get Mouse Position (Java): http://stackoverflow.com/questions/1439022/get-mouse-position
- How can I get the monitor size in java?: http://stackoverflow.com/questions/3680221/how-can-i-get-the-monitor-size-in-java#3680236
- Developing Draggable Applets: http://docs.oracle.com/javase/tutorial/deployment/applet/draggableApplet.html
- Opening a URL from an Applet: http://www.roseindia.net/java/example/java/applet/Opening-a-URL-from-an-Applet.shtml
- Java-Javascript integration: https://www.rgagnon.com/topics/java-js.html (JSObject & javascript:myThing(); URLs from Java-->JS, document.myApplet.myMethod(); from JS-->Java, where Applet loaded via <applet name="myApplet" code="com.mypackage.MyApplet.class" width="600" height="400"></applet>)
- Call a Java method from Javascript: http://www.rgagnon.com/javadetails/java-0170.html
- JavaScript to Java Communication (Applet Scripting): http://download.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/js_java.html[25]
- Call Javascript from a Java applet: http://www.rgagnon.com/javadetails/java-0172.html
- Java-to-Javascript Communication: http://download.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/java_js.html
- Applet-to-Applet Communication: https://www.javatpoint.com/Applet-Communication
- Java Web Start (Jnlp) Tutorial with JAR Signing instructions: http://www.mkyong.com/java/java-web-start-jnlp-tutorial-unofficial-guide/
- I did it again... I lost my JAR-signing keys!: http://gemsofprogramming.wordpress.com/2012/02/15/i-did-it-again-i-lost-my-keys/(steps to sign your own JAR/JNLP files and get past "enter key password for <jdc>")
- Use the Java plugin to view interactive content on websites: https://support.mozilla.org/en-US/kb/use-java-plugin-to-view-interactive-content
- Applets & Web Start Applications- Java Rich Internet Applications (RIA): https://www3.ntu.edu.sg/home/ehchua/programming/java/J4c_AppletWebstart.html
- Signing and Verifying JAR Files: http://docs.oracle.com/javase/tutorial/deployment/jar/signindex.html
- Creating a Java WebStart (JNLP) application: http://jansipke.nl/creating-a-java-webstart-jnlp-application/
- Deploying a Java Web Start Application: https://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html
- How to Use Java, Silverlight, and Other Plugins in Modern Browsers: https://www.howtogeek.com/221720/how-to-use-java-silverlight-and-other-browser-plug-ins-on-windows-10/
- Fun with Java2D - Java Reflections: www.jhlabs.com/java/java2d/reflections/index.html
- Applet examples: http://www.java-examples.com/applet
- Java Examples - display a clock using Applet?: http://www.tutorialspoint.com/javaexamples/applet_clock.htm
- What are some examples of Java Applets?: https://www.quora.com/What-are-some-examples-of-Java-Applets
- Java Applet basics: https://www.geeksforgeeks.org/java-applet-basics/
- Java Code for Moving Text - Applet - Thread: https://www.geeksforgeeks.org/java-code-moving-text-applet-thread/
- Creating Animation in Java: http://www.dmc.fmph.uniba.sk/public_html/doc/Java/ch10.htm#CreatingAnimationinJava[26][27][28][29][30]
- Creating a First-Person Shooter Game, Math for Java Game Programmers: http://www.developer.com/java/other/article.php/3785601/Creating-a-First-Person-Shooter-Game-Math-for-Java-Game-Programmers.htm#Run%20the%20program
- How to Program Pong in Java: https://www.youtube.com/watch?v=xIqeK2hzx1I | SRC
External Links
- wikipedia: Applet
- SUN Java Lesson - Applets: http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/deployment/applet/index.html
- Java Applet overview: https://www.javatpoint.com/java-applet
- Java Applets, ASP.net - Can You Play Together?: http://java.sun.com/developer/technicalArticles/appletAspIntegration/
- The Wide World of Applets: http://lessonplans.btskinner.com/applet.html
- What type of .avi video jmf plays?: https://stackoverflow.com/questions/17899557/what-type-of-avi-video-jmf-plays
- Java Applets "Dead Man Walking?" Is a Comeback Impossible?: http://java.dzone.com/news/are-java-applets-dead-man-walk
- Error: Could not find or load main class sun.applet.AppletViewer: https://stackoverflow.com/questions/54505959/error-could-not-find-or-load-main-class-sun-applet-appletviewer (need to ensure both your project-level and compiler-level are set to Java 8 or lower)
- J is for Java -- 1990–2000 (1 of 2): http://hackernoon.com/the-fifth-decade-of-programming-j-is-for-java-5694bf59c5ae
- JavaFX is now out - Are Applets and Java Desktop officially dead/dying?: http://stackoverflow.com/questions/377593/javafx-is-now-out-are-applets-and-java-desktop-officially-dead-dying
- Applet and JavaFX and Confusion: http://blogs.oracle.com/vaibhav/entry/applet_and_javafx_and_confusion
- JavaFX... it does have a future too: http://mkblog.exadel.com/2010/07/javafx-it-does-have-a-future/
- JavaFX living the applet dream: http://www.javaworld.com/community/node/2546
- Are applets making a comeback?: http://www.javaworld.com/javaworld/jw-05-2008/jw-05-applets.html
- The new applet experience: http://www.javaworld.com/javaworld/jw-05-2008/jw-05-newapplet.html
- JavaFX Does Have a Future: http://java.sys-con.com/node/1483065
- Advanced Tricks for Java coders: https://dzone.com/storage/assets/162172-advanced-tricks-for-java-coders.pdf
- Oracle Finally Kills the Java Web Plugin: http://dzone.com/articles/oracle-finally-kills-the-java-web-plugin
- Where did all the java applets go?: http://stackoverflow.com/questions/51390/where-did-all-the-java-applets-go
- I can't run applet on my FireFox browser: https://askubuntu.com/questions/407659/i-cant-run-applet-on-my-firefox-browser
- I can't run my own applets in browser: https://stackoverflow.com/questions/30290893/i-cant-run-my-own-applets-in-browser
- Can't run JApplet - Impossible to load library for security problems: https://stackoverflow.com/questions/24311091/cant-run-japplet-impossible-to-load-library-for-security-problems
- How to load signed applet from local disc with full permissions?: https://stackoverflow.com/questions/5182160/how-to-load-signed-applet-from-local-disc-with-full-permissions
- OS X 10.8 Gatekeeper and Java Applets (now shoing "unsigned" warning when actually signed): https://stackoverflow.com/questions/11665386/os-x-10-8-gatekeeper-and-java-applets/12210534#12210534
- Oracle -- Further Updates to 'Moving to a Plugin-Free Web': https://blogs.oracle.com/java-platform-group/further-updates-to-moving-to-a-plugin-free-web[31]
- Oracle -- Migrating from Java Applets to plugin-freeJava technologies: http://www.oracle.com/technetwork/java/javase/migratingfromapplets-2872444.pdf (Applet, JApplet & related classes, along the appletviewer utility are to be marked as “deprecated” when JDK 9 launches... Oracle suggest instead using one of: JavaFX/WebView, JavaWebStart/Swing, javapackager... in that order)
- The Rise & Fall of the Java Applet -- Creative Coding’s Awkward Little Square: https://www.vice.com/en_us/article/8q8n3k/a-brief-history-of-the-java-applet
- Oracle blogs -- Moving to a Plugin-Free Web: https://blogs.oracle.com/java-platform-group/moving-to-a-plugin-free-web (advises using JWS rather than Applet runtime plugin)
References
- ↑ Flash Satay - Embedding Flash While Supporting Standards: https://alistapart.com/article/flashsatay/
- ↑ Introduction to the AWT -- description of Java's user interface toolkit: https://www.javaworld.com/article/2077188/introduction-to-the-awt.html
- ↑ Java AWT Tutorial: https://www.javatpoint.com/java-awt
- ↑ The "new" AWT Tutorial: http://www.eng.auburn.edu/~rayh/java/java/AWT.Tutorial.html (top tutorial back in 1995-1996 when AWT first came out)
- ↑ Overview of the AWT: https://staff.fnwi.uva.nl/a.j.p.heck/Courses/JAVAcourse/ch5/s1.html
- ↑ Java AWT tutorial for beginners: https://beginnersbook.com/2015/06/java-awt-tutorial/
- ↑ AWT Tutorial: https://www.tutorialspoint.com/awt/ | PDF
- ↑ Java AWT Graphics Example: https://examples.javacodegeeks.com/desktop-java/swing/java-awt-graphics-example/
- ↑ "Java in a Nutshell", by David Flanaga (BOOK): http://web.deu.edu.tr/doc/oreily/java/javanut/index.htm | AWT changes section (Freely available online now)
- ↑ "Java AWT Reference", by John Zukowski (BOOK): https://www.oreilly.com/library/view/java-awt-reference/9781565922402/
- ↑ Brewing Java - A Tutorial: http://www.cafeaulait.org/javatutorial.html (from 1990s Java approaches... in 2019 not THAT different, well except for Lambdas/Functional stuff)
- ↑ Java AWT Code Examples: https://java.happycodings.com/java-awt/
- ↑ Java Code Examples for java.awt.Frame: https://www.programcreek.com/java-api-examples/java.awt.Frame
- ↑ jlGui - Music Player (JNLP Launch file configurator for standalone desktop application version): http://www.javazoom.net/jlgui/jnlp_configurator.jsp
- ↑ Two Player Pong: http://www.jdonohue.com/java/pong/two_player_pong/two_player_pong.html
- ↑ Pong Applet:http://forums.devshed.com/java-help-9/pong-applet-667776.html
- ↑ http://javaboutique.internet.com/SimplePong/
- ↑ http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3234&lngWId=2
- ↑ How to Form a TCP Connection Between a JavaScript Program and Java Server: http://pharos.ece.utexas.edu/wiki/index.php/How_to_Form_a_TCP_Connection_Between_a_JavaScript_Program_and_Java_Server
- ↑ StephenWare's Java-JS Socket Bridge (Fork with minor improvements): http://github.com/ihilt/JavaSocketBridge
- ↑ Applet game demos: http://www.mscs.mu.edu/~mikes/174/demos/
- ↑ Running an Applet in Netbeans: https://ubuntuforums.org/showthread.php?t=872378
- ↑ Resizing an applet by overriding its original size: https://www.decodejava.com/resize-applet-window.htm
- ↑ Java Applet Windows size in Eclipse: https://stackoverflow.com/questions/19367320/java-applet-windows-size-in-eclipse
- ↑ Invoking Applet Methods From JavaScript Code: http://download.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html
- ↑ Move text left and right in Java GUI: https://stackoverflow.com/questions/50082818/move-text-left-and-right-in-java-gui
- ↑ Animation in Applet: https://www.javatpoint.com/Animation-in-applet
- ↑ Applet - Simple squares and cube with for loop: https://stackoverflow.com/questions/28337502/applet-simple-squares-and-cube-with-for-loop
- ↑ Fill Rectangle & Square in Applet Window Example: https://www.java-examples.com/fill-rectangle-square-applet-window-example
- ↑ Java Applet program to show the animation of a bouncing ball: https://www.includehelp.com/java-programs/show-the-animation-of-a-bouncing-ball.aspx
- ↑ Oracle Reminds Java Developers That Soon They Won’t Have a Browser to Run Applets: https://www.infoq.com/news/2017/02/oracle-java-browser-applet