Thursday, February 4, 2016

Java Endorsed

What is the concept of endorsed directory??
To put it in simple words , Suppose I have a class called Some.class which is present in two jar files named file1.jar and file2.jar.

Suppose I have following  directory & file structure:
  • lib\file1.jar
  • lib\endorsed\file2.jar

Then Some.class will be called from file2.jar get called.

More Details at
  • http://docs.oracle.com/javase/6/docs/technotes/guides/standards/ 
  • http://stackoverflow.com/questions/2859471/what-is-the-exact-way-to-use-endorsed-directory-in-jdk1-6 
Way to do it in pom.xml

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
            <compilerArguments>
                <endorseddirs>${endorsed.dir}</endorseddirs>
            </compilerArguments>
        </configuration>
    </plugin>
</plugins>
 


Why do i need it ?
 it is a mechanism to provide newer versions of an endorsed standard than those included in the Java 2 Platform.
 
Which means, a user can provide newer versions of certain packages than those provided by the JDK. If there are newer implementations of these packages in the directories specified by java.endorsed.dirs, those implementations will be loaded instead of the default ones that come with the JDK.

Roughly speaking the Endorsed Standards APIs include:
  • javax.rmi.CORBA
  • various org.omg.* packages
  • org.w3c.dom
  • various org.xml.sax.* packages

No comments: