Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
At the top of the java.awt.Button class's source file there's the statement
package java.awt ;
because that's the package where Button belongs, among the other visual components.
Its full name is :
Likewise, this example class's fully qualified name is :
This also indicates how Packit.class must be stored .
It WILL NOT RUN, if it's in a different directory structure ! A security aspect.
That's why the first CODE attribute in HTML functions properly, and the others don't :
CODEBASE indicates a 'starting point', where the directory branch has its origin. In our example it indicates the folder httpdir .
In this case it could be omitted, the dot meaning : same directory as where the HTML is from.
The next APPLET tag will fail, because the class won't be found .
And this one will be found but will fail, because the full name contained in the class doesn't match the name Packit .
Of course, the package statement used as an example is highly unusual. Common practice is, to have something like :
package nl.semm.utils ;
meaning, that the class in this file is part of the utilities package of the SEMM company.
Ideally, this should match an organization's www-address :
www.sun.com package com.sun........
www.ibm.com package com.ibm........
www.omg.org package org.omg........
thus guaranteeing UNIQUE NAMES for all packages.
This actually means : we want to use classes that are in the java.awt package.
A stand-alone application with a main class by the name of
present in this tree :
can be run by going to the entrancedir directory and from there issue a command similar to this.
There's no need to go to the entrancedir directory if you specify a CLASSPATH.
It WON'T RUN if you try to start Klaz from the semm folder.
To ensure efficient transport, class files (+ images and other resources) can be zipped into one file, say, pekapp.jar .
The HTTP server situation would then be like this,....
so the package directory structure is in the jar file.
The HTML file has to contain this attribute. jar = Java archive .
For standalone applications, a classpath can also be set as an environment variable, f.e.
If there's a newer version of a class inside pekapp.jar and an older version under entrancedir, the older one will be loaded and the new one won't, so
THE ORDER IN A CLASSPATH IS CRUCIAL !