rcreswick
rcreswick

Reputation: 16823

What are the java platform defaults?

Many parts of the Java API work differently depending on platform defaults, for example, creating a Sax parser from a SAXParserFactory uses a different Factory implementation based on the system property "javax.xml.parsers.SAXParserFactory". However, if that property is not defined, then the "platform default" is used.

I've had very little luck finding out what the platform defaults actually are for any given JVM/platform. This would be very useful to know when you need to deploy to multiple platforms, or when you're debugging something and need to learn more about the specific implementation.

Where can I find a list of these defaults (often system property names) and the default values for assorted platforms?

Upvotes: 4

Views: 843

Answers (3)

Vineet Reynolds
Vineet Reynolds

Reputation: 76709

The Platform default implementation, in most cases, happens to be a fallback class that is always available in the 'platform'. In these cases, the platform has been interpreted (sensibly, I must add) as the Java Runtime Environment installation. After all, only the platform provider can state what a default should be. In the case of an application server, the definition could be extended to include the environment provided by the application server, and not just the Java runtime.

For instance, JREs in Sun Java 5 and above, will use "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl" as the fallback implementation for SAXParserFactory. This is primarily because JREs from Sun (atleast from Java 1.4 onwards) come with a complete JAXP implementation.

You can refer to the source code of the SAXParserFactory and FactoryFinder classes (in the javax.xml.parsers package) to take a peek as to how this is done. It would be interesting to know what Sun used to do in Java 1.3, but I'm not sure on whether the sources are available.

Since application servers have been mentioned in this context, it would be a good thing to remember that certain application servers (Weblogic for instance), set the SAXParserFactory to be used by all the applications at the level of the server. Applications could override it at the application level; Weblogic allows you to do this via the weblog-application.xml configuration file. It could be overridden at the server-level (multiple servers constitute a Weblogic domain), or at the domain level itself, with the lowest (most applicable) configuration taking precedence.

Getting the list of platform defaults (rather, an attempt to)

As you might have figured out by now, obtaining the default values for different platforms can be difficult, especially when you have to worry runtime environments (Sun, IBM, Oracle have their own runtimes; you also have Apache Harmony, GCJ, Kaffe etc. to add to the mix) and application servers as well. The platform defaults can also vary from one platform to another, more so for application servers rather than actual Java runtimes (application servers on IBM AIX will not look for the Sun Java platform fallback).

Upvotes: 1

RealHowTo
RealHowTo

Reputation: 35372

Tolstoy.com used to have a page with the default values for various OS but it's gone now ... but you can retrieve it with the Internet Way-back machine !

http://web.archive.org/web/20070724075948/http://tolstoy.com/samizdat/sysprops.html

Upvotes: 3

Yishai
Yishai

Reputation: 91881

As a general question, that depends heavily on the specific default under discussion. In the specific case of the SAX parser, you have to realize that the Java spec is written with the idea that more than just Sun (now Oracle) will implement it. So when it says the "Platform default" SAXParserFactory, it means whatever the JVM implementer decides to return as the default. In the Sun JVM case that is a modified Apache Xerces implementation.

I'm not aware of any "these are our default implementations" list from any JVM implementers. But for a given default, it isn't hard to find.

In other contexts, platform default can refer to the operating system (like time zone, file separator and the like).

Upvotes: 0

Related Questions