WORA help required

Mark L. Fussell fussellm at alumni.caltech.edu
Sun Nov 30 01:19:59 GMT 1997


Peter Murray-Rust <peter at ursus.demon.co.uk>:
> I am having a number or problems turning JUMBO into a WORA-compliant animal
> (WriteOnceReadAnywhere).... 

You might want to also ask these questions on advanced-java.  There are a 
lot of good people on that list and your questions are interesting and 
applicable [the only ones "questionable" to the charter of the list have 
to do with applets, but your code is for both].  I will try to answer 
some of them here.  All my answers will be 1.1 oriented since this is all 
I have been using recently.

> A JDK1.02/JDK1.1.x
>         I have refrained from converting to 1.1. since I have been told 
that not
> all browsers supported it. Is this still true? Or should I convert now?

I think you will be "trapped" supporting 1.02 for a while if you want to 
support as many browsers as possible.  For example, I still use Netscape 
3.x because it is extremely stable.  By my web logs that a lot of 3.x 
(and earlier) browsers still out there.
   Note that at the VM level there are very, very few changes between 1.0 
and 1.1.  The real problem is that the class libraries have migrated and 
if you migrate also you will not be backward compatible.

> B.1 Is there a function I can call to tell whether I am in an applet or
> application? 

Yes (maybe) but I don't remember what it is :-(  It also somewhat depends 
what you want to know.  You can find out about the overall environment 
with System.getProperties() [if you want to find out about the host VM 
which may indicate appletness] and you can find out about the ClassLoader 
and SecurityManager from their respective sources.  I think the only 
object that really knows its an Applet is the Applet itself, so to 
propogate this knowledge outward requires either a web of associations to 
the Applet or some "static" information.  The later can be very clean if 
you simply have a registry where you can put applet information (which 
obviously includes their existence).  It sounds like you are doing 
something like that anyway.  Again, I recall there existing another 
approach but don't remember.  Someone on advanced-java would probably know.

> B.2 I use ancillary files located in the *.class directories (e.g
> icon.gif). A nice extension in JUMBO is a per-class schema.xml file, with
> additional class information. Since CLASSPATH may contain many components,
> how can I tell which component was used for the class I am now running, so
> I can locate these files?

Use Class#getResource(...).

If you are in a particular object: 
    URL url = this.getClass().getResource(relativePathName+fileName);
The relativePathName should be from the current Class (in your case it 
would probably be empty).

If you are in a static method you need to explicitly specify the class 
object:
    URL url = ThisClass.class.getResource...
Because static methods are not connected to any object (they are 
completely resolved at compile time).

> D java/jview
>         There are significant differences here, especially with 
filenames/URLs.

No solutions, just a couple comments.  The 100% Pure tester warns about 
all hardcoded '/' and '\', so these are obviously considered non-WORA.  
For most of these you can use either the functionality within a class 
(File concatenation) or the System.properties:
     * <dt>file.separator	<dd>File separator ("/" on Unix)
     * <dt>user.home		<dd>User home directory
     * <dt>user.dir		<dd>User's current working directory
     * <dt>java.home		<dd>Java installation directory

URL's should generally work with standard URL notation (it is up to the 
implementation to work correctly).

--Mark
mark.fussell at chimu.com



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list