Hello Christopher Giblin,
Monday, April 29, 2002, 12:20:24 PM, Christopher Giblin wrote:
CG> I realize my remark is beyond the scope of this mailing list, but querying
CG> an arcane class name or proprietary name/value pair in the manifest is not
CG> portable.
Yes, it is.
Try this:
----------------8X----------------8X----------------8X----------------
import javax.xml.transform.*;
class JAXPVersionTest {
public static void main(String[] args) {
TransformerFactory tFactory = TransformerFactory.newInstance();
Class clazz = tFactory.getClass();
Package pakkage = clazz.getPackage();
System.out.println(
"Class: " + clazz.getName() + "\n" +
"Package: " + pakkage.getName() + "\n" +
"Version: " + pakkage.getImplementationVersion());
}
}
----------------8X----------------8X----------------8X----------------
This is the output when running the code with JDK 1.4:
----------------8X----------------8X----------------8X----------------
Class: org.apache.xalan.processor.TransformerFactoryImpl
Package: org.apache.xalan.processor
Version: 1.4.0
----------------8X----------------8X----------------8X----------------
Of course the version number is a little bit confusing here.
But the mechanism is working:
Using JAXP to get a transformer instance (implementation independent),
using reflection to get the transformer class and package
(implementation independent, API independent), get the version number
(implementation independent).
Best regards,
Jens
BTW:
Xalan 2.3.1 already comes with a manifest file, but I had some
problems using it to dedect the version with JDK 1.3.1 and JDK 1.4.0.
The returned version string was "null".
The following manifest is working as expected (all name sections are
deleted):
----------------8X----------------8X----------------8X----------------
Manifest-Version: 1.0
Main-Class: org.apache.xalan.xslt.Process
Class-Path: jaxp.jar xerces.jar crimson.jar xml-apis.jar
Specification-Title: Java API for XML Processing
Specification-Vendor: Sun Microsystems Inc.
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/xalan-j/dist/
Specification-Version: 1.1
Implementation-Version: 2.3.1
----------------8X----------------8X----------------8X----------------
Simply adding a section for the processor packae didn't help.
Using this manifest the following output is generated:
(jdk 1.4.0)
C:\tmp>java -Xbootclasspath/p:xalan.jar JAXPVersionTest
Class: org.apache.xalan.processor.TransformerFactoryImpl
Package: org.apache.xalan.processor
Version: 2.3.1
(jdk 1.3.1)
C:\tmp>java -classpath "xalan.jar;" JAXPVersionTest
Class: org.apache.xalan.processor.TransformerFactoryImpl
Package: org.apache.xalan.processor
Version: 2.3.1