Java For Complete Beginners

Java Information: Where to get it

Some useful facts

Sod Java: I just want the toys

Have you ever been to a site, and seen text scrolling along the bottom, or a Java message pop up, or a little window appear and tell you your username? Ever wondered how it's done? Yeah, me too; so I embarked on a fact-finding tour to see if I could master the art. Below is a summary of what I learned, some useful links, and a few Java toys for you to take away.

The first approach that I tried, was to go to the sun site at http://java.sun.com and download the software development kit (7.75Mb) and the documentation (1.83Mb), in the hope that it would contain instructions at beginner level. The documentation contains more than 700 HTML documents very tidily linked together, but unfortunately makes the assumption that you are an experienced programmer. From a non-programmer's point of view the documentation starts at incomprehensible and gets rapidly worse. There is an online tutorial that is at http://java.sun.com/nav/read/Tutorial/index.html but the tutorial is split into many separate pages and could be very stressful when it is time to pay the phone bill. You can download the tutorial in HTML format (6.1Mb), zipped (3.2Mb) or TAR compression (3.9Mb). For a download, go to the above site, select "other information", then "download". The help consists of 1383 HTML files, all linked together. It looks very nice, but there is an awful lot of jumping around. Nevertheless, if you have a question about Java, the answer is probably in there.....somewhere.

For those of you who prefer your tutorials in a more linear form, there is Brewing Java: A Tutorial by Elliote Rusty Harold. The document is one long page (229k); if you printed it out, it would cover 78 pages with small writing. The language is more stilted, and there are few links within the page, but at least it has a start and a finish. Brewing Java can be found at http://sunsite.unc.edu/javafaq/javatutorial.html . A Java FAQ document has been developed alongside the tutorial, and there is a link within the page.

 

Some Useful Facts

Without being too boring on the subject, Java is an object-oriented programming language. A Java routine can be an entirely self-supporting program. Javascript, on the other hand is not self supporting, and is used for jazzing up HTML (Hyper Text Mark-up Language- the language is used to build web pages). If you are using a Java applet within a web page, chances are that there is a little bit of Javascript in the page that calls the applet when you want it. A Java file always looks like this: "[filename].class", (the quote marks are mine).

Java is not easy to learn, as a brief glance at either of the above tutorials will show you.

 

Toys

If you want the toys (or applets, if you're going to get technical), but can't be bothered to learn Java, then here's how to get them:

Firstly, you will find this much easier if you are familiar with basic HTML code. If you're not, then a visit to http://www.htmlgoodies.com will definitely be a good idea. The HTML Primer there is very good indeed. Anything that teaches in 7 lessons how a website can be built, with no prior experience, using only a word-processor (notepad in Windows 95) and a web browser, has got to be worth a look.

A Java applet is called into a web page by Java script. So if you want a working applet, you need to collect at least 2 parts: the applet, and the script that calls it into the page.

The script is easy to get. The code for the flashing Java cup at the top of this page is embedded in the HTML code that this page is constructed from. You need to look at the code, so with your browser, click on "View" and ("Document Source" for Netscape) and ("Source" for Internet Explorer). You can now see the HTML details. Yes, I know that it looks like gibberish, but you are only looking for a bit that says "<applet code=". This is the start of the script that calls the Java applet. The end is the bit that says </applet>. The script for the cup at the top, therefore looks like this:

<applet code="Neon.class" align="baseline"
width="296" height="61"><param name="picture1" value="neon1.gif"><param
name="picture2" value="neon2.gif"></applet>

Here's what it means:

<applet code="Neon.class" start the Java program called Neon.class align="baseline"put the bottom of the Java window level with the bottom of the text on this line width="296" height="61" this is the size of the Java window, in pixels ><param name="picture1" value="neon1.gif"> the first picture that the program will use is called neon1.gif. the program will refer to it as picture 1 <param name="picture2" value="neon2.gif"> the second picture...etc...</applet> end of script

How to get the script in Windows 95: Open a copy of Notepad. Look at the document source in your browser. Highlight the script that you want. Click on "Edit" then "Copy". The data is on the clipboard. Click on Notepad. In the Notepad window, click on "Edit" then "Paste". You now have the code. Save the Notepad document as, say, neoncode.txt, and it's yours forever. To get the code onto your web page, all you have to do is reverse the process and copy/paste it into whatever .HTM document that you are working on. NOTE: if you are using a HTML-building bit of software (Micro$$oft FrontPage being a case in point), it may juggle your script around a bit, thus wrecking the program. It is therefore a good idea to copy/paste your scripts in AFTER you have written the rest of the page, and have finished with the software.

The Files Your applet is a Java applet, so you know that you will need at least 1 thingy.class file. Looking at the script, you can tell that it's called Neon.class. You can also see that 2 thingy.gif files are used, so for the applet to work you will need 3 files:

Neon.class

neon1.gif

neon2.gif

Click on the above links to download. NOTE: when you click on Neon.class, all you will see will be a blank screen and some worrying squiggles at the top. Don't worry, just click "File" then "Save As", and make sure that the name is Neon.class (for some browsers, you may have to use a "save as raw data" option). Java applets ARE case sensitive, so make sure that any capitals are included.

So, you've got your HTML page, you have copy/pasted in the script. Copy the relevant files into the same directory that your HTML page is in; open the page in your browser and Bingo!- a working Java applet.

Here are some more applets:

Ashleyticker

Gamma Button

Urname

Scripts can be fun on their own...

Autoexec- waits 30 seconds, then shows you YOUR autoexec.bat

Scrolling along the bottom of the screen

Popup menu

These are just a few samples. There are lots of sites out there offering free applets for downloading and here are a couple of good places to start:

The Java Boutique : Sun Microsystems Java : Gamelan : TeamJava : Netscape's Java Applets Page : Yahoo's Java Directory

 

Have Fun !

Back to top

 

Credits: Scott Clark (Neon); Ashley Cheng (Ashleyticker); Elijah Meeker (Gamma Button); Amit D Chaudhary (Urname); Anon (Autoexec- no one will admit to it); Chris Skinner (Text Scrolling); Paul Tahan Jr (Popup Menu)