Thursday, December 12, 2024

What is a Java Applet? (with Examples)








…know this person?

Use these to jump around or read it all…


[What Is Java Anyway?]

[Why Is It Called An Applet?]

[The Concept of Class]

[Getting The Applet]

[Call For The Applet]

[Getting Other Applets]





What is the difference between Java and JavaScript?



What Is Java Anyway?


     Java, sometimes called HotJava, is an object-oriented
programming language created by Sun Microsystems.


(Huh?)

     Sun Microsystems is a computer
company. They make high-end Internet servers and other UNIX
(that’s an operating system) material. In other words, these
people are real players in the Internet business.

     Object-oriented programming
language
refers to the construction of the programming
language. The programming language is set up as if its parts are not as important as the whole. Java is like a model. There are many parts that make up the whole. However, the parts are useless by themselves. They must work in tandem with others like them. The objects make up the whole. Object-oriented programming. That’s the quick explanation.

Why Is It Called An Applet?

     Java, as outlined above, is a
grouping of objects. A “class” of objects, actually (more on
that later). The Java applet is itself a fully functioning little program. It’s an application, but it’s a little application: An applet, in other words.

The Concept of Class

     You know how the Internet works by giving everything a name and then a suffix? In computer terms it’s called “association.” An example is “image.gif.” Image is the name of the item and .gif is its form. Any page on the Web is done the same way. The name of the page you are looking at right now is “applet.html.” The name of the page is applet and the type of page is html.

     By doing this, the computer can
tell all these different files apart. It “associates” an application with the item’s form. Images are displayed using an image viewer, html pages are displayed using the browser, etc. Basically, once the computer sees what the item is by its suffix, it knows what application to get to use the item.

     Well, these applets work the same way. The computer sees the applet as a name and then a suffix. In terms of an applet, the suffix is “.class.” Remember that applets are models made up of many little parts, a “class” of parts? Just as species are broken up into classes, so are applet parts. An applet is a class of like parts. Thus you will name the applet you are using in this fashion: applet.class. Get it?

     But my IBM machine won’t let me put five letters after the dot! I’ll bet you use Windows 3.x. That won’t work here.

Do I Have To Write My Own Java Applet?

     Ha Ha Ha Ha Ha…! No. Java applets are available all over the Net. I’ll tell you how to get and use any offered applet. Please… use only offered applets. Don’t steal someone else’s work. There are easily enough applets available for you without taking another’s work.


Getting The Applet

     Okay, here we go. People believe this Java stuff must be hard because it requires all these little stipulations. Actually, Java is pretty easy. It is just reeeeeeeaaaaally testy. It likes everything to be just so. If it isn’t–tough. No Java for you!

What You Need:


  • An applet (no kidding) and…
  • A series of lines in your HTML document that call for the applet.

The Applet Above

     That thing at the very top of the page is an applet. It reads the domain of the person viewing the page. Dull, yes–but it’s excellent for teaching the process. It’s small, loads quickly, requires little html text, and works quite regularly.

     First off, get the applet. You can take it right off of my server. When you click on the applet link below, you’re going to think I tricked you. The screen will go blank and some silly squiggly lines will show up. THAT’S IT! Save the applet as “All Files”, “Source”, or “Raw Data”, depending on the system you are using. You can name it whatever you want, but make sure to add the suffix .class.

     To ensure a good download, Netscape users can hold the shift key while clicking. MSIE users can click the right mouse button and choose to download. MAC users can hold the mouse button and choose download. Doing this will often solve later problems.


Click here to get it!

Call For The Applet

     Where you want the applet on your page is where you will place the HTML call for the applet. Here is the text you require to run the applet above:

<APPLET CODE=”urname.class” WIDTH=”250″ HEIGHT=”22″>
</APPLET>



Feel free to just copy and paste what you see.

What Is Happening:


  • APPLET CODE calls for the applet you just downloaded.
  • WIDTH and HEIGHT define parameters in which the
    applet can work. You have to have this.
  • /APPLET ends the whole thing.


Now, FTP (or upload) the applet and the HTML document into the same directory on your server.
The applet should download into the browser, run, and post the results of who is looking at your page very quickly.



Is That It?!


     Yes. That’s it. If you haven’t
corrupted the applet through downloading or FTP transfer, the
applet should run just fine. I’ve gotten this pup to work three different times on three different servers.

     The applet downloads, then runs like the little program that it is.


Where Do I Get Other Applets?


     All over the place. I like Java Boutique best. There are hundreds of Java applets to browse and all are grab-able. (Is that a word?)

     Follow the instructions
provided. You are given a link, like the one up this page a bit, to grab the applet–do it the same way as you did here.

     It is easy to find the HTML text you require by simply downloading the source of the page that is currently running the applet and cutting and pasting it. That’s how I get all my applets. Just remember, you may have to alter the text a bit so it conforms to your specific server. It’s not hard, but what you have seen here is very simple as compared to many of the applets you’ll find out there.

…now go get that applet and get ready to be frustrated. These things will do it.


Thanks for coming by.





[What Is Java Anyway?]

[Why Is It Called An Applet?]

[The Concept of Class]

[Getting The Applet]

[Call For The Applet]

[Getting Other Applets]

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Popular Articles

Featured