The following is an html counter. It is contained in html brackets and reads

!--#exec cgi="/cgi-bin/counter-ord"--

When you review the page you will find it has changed to numerals and will have to be re-written every time you change your page to continue counting. You will get an error message if it is typed in upper-case.

You are the
visitor to these pages since 19th December 1999



I am just learning to write Java and these are my notes, beginning 23rd November 1999.


Java is an object-oriented language that was created by Sun Microsystems, Inc. It is similar in appearance to C++, and programs for web pages (known as applets) written in Java can be run on any machine that has a Java-enabled browser.

The Java applets are written outside of an HTML file and saved with the extension .java. The Java compiler (javac) is then run to compile the source code into a .class file.

After compilation, it is possible to link your Java applet via an applet "tag", directly into a web page. In addition, Java code can be compiled into standalone applications.

NOTE TO SELF: 19th December 1999 .. I suspect the following is pure nonsense written to confuse people, as it didn't work and I couldn't make anything of it. My cousin's program further down the page is much simpler and works just fine!

Further note to self: 10th October 2001 .. The problem was - I did not understand that although my browser reads Java, I do not actually have Java on my computer. Sun Microsystems could not tell me this and their office in Toronto did not reply to my question about it. So, now I am taking an on-line course with a local college. I have now loaded Java from Sun Microsystems. It was a big programme and took 2½ hours on my 32modem to load. I also had to load an updated "TextPad" which is helpful with a compiler and notes to point out errors. To date I still have not yet put a programme on this page using Java.

The following is a very short program called "Hello World":


class myfirstjavaprog

{

public static void main(String args[])

{

System.out.println("Hello World");

}

}

Code : myfirstjavaprog.java


You should type this code out, using your preferred text editor, and save it as 'myfirstjavaprog.java'. Place this file in a directory (for example, "c:\src\") of its own, not your Java installation directory. Its best to keep your tools and source code separate.

Java compilers expect the filename to match the class name. Thus the class, myfirstjavaprog, must be saved as myfirstjavaprog.java

Compiling your first Java application

While some languages are interpreted (such as PERL), others introduce an extra step, called compilation. Compilation takes source code (files ending in a .java extension), and converts it into byte-code. This byte-code is low level machine code, which is executed inside a Java Virtual Machine (JVM).

To compile Java code, we need to use the 'javac' tool.
This ships as part of the JDK, (Java Developers Kit) so if you have it installed and in the current path, you can compile your application using the following command from any DOS prompt or Unix session :
javac myfirstjavaprog.java
This will produce a Java class file, called myfirstjavaprog.class.

Once your program is in this form, its ready to run.
Check to see that a class file has been created. If not, or you receive an error message, check for typographical errors in your source code.

Running your first Java application

Now the time has come, (said the Walrus). You're ready to run your first Java application.
From a dos prompt or Unix session, enter the directory where your source code and class file is stored, and type the following : java myfirstjavaprog Your Java application will load, display its message, and then terminate.

Congratulations!

Summary Writing and developing Java applications and applets need not be a great mystery. Armed with the JDK and a text editor, virtually any programmer can write in Java. You've just taken the first step, in a long journey, towards learning Java.

Well, that didn't help me much. I found "Java for Dummies" at the library and decided to type in the following from Page 76- remember, each of these lines must go between the <> brackets for it to work on the web pages:) Also, if you type in PRE before and /PRE after anything, such as a poem, then you don't have to re-do all the line breaks. .. I haven't tried that before.


APPLET CODE="Marquee" WIDTH=500 HEIGHT=40
    PARAM NAME="font_face" VALUE="TimesRoman"
    PARAM NAME="font_size" VALUE="24"   
    PARAM NAME="font_italic" VALUE="yes"
    PARAM NAME="font_bold" VALUE="yes"
    PARAM NAME="font_color" VALUE="#FF0000"
    PARAM NAME="marquee" VALUE="Merry Christmas"
/APPLET

Unfortunately you will not be able to see Merry Christmas actually scrolling across the page unless you have a Java savvy browser. You could get one when Java for Dummies was printed at netscape.com.

Well, back to the drawing board ! That didn't work for me and I thought I had a Java savvy machine - it reads other people's Java. I must be doing something wrong here. In my notes it said that the script has to be saved in a separate file, so when I get time I'll try doing that.

Well, none of that worked, so I contacted my cousin and he gave me this very simple piece of code - which works and has none of the above-mentioned complications. It does have to be put in the usual <> brackets to work - so wherever they should be I have put () ordinary brackets:-

(FONT COLOR="RED")(b)(MARQUEE BGCOLOR="GREEN" HSPACE=15)MERRY CHRISTMAS and A VERY HAPPY NEW YEAR(/MARQUEE)(/FONT)(/b) (!---Page Heading---)

As you can see, the lower-case b seems to be for bold lettering and HSPACE seems to mean a 15 letter space in the lettering. The Page Heading with exclamation means he was making a comment on the use of that line.

MERRY CHRISTMAS and A VERY HAPPY NEW YEAR


Java1 is a sub-page of OFICSERV Computer Office Services.