Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is endorseddirs and how it is used in a application?

Tags:

java

maven

In respect to the maven-compiler-plugin. There is a setting added to my project's POM file. The configuration is given below.

<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> 

What does it mean to have a <endorseddirs> in the compiler arguments? How does it works with java compiler?

like image 992
Vijay Shanker Dubey Avatar asked Feb 05 '11 18:02

Vijay Shanker Dubey


People also ask

What is endorsed directory in java?

endorsed. dirs specifies one or more directories that the Java runtime environment will search for such JAR files. If more than one directory path is specified by java.

How do I get rid of java endorsed DIRS system property?

In Windows, open the QIE Service Manager, and click the Startup tab. In the Arguments section remove the highlighted line below (which contains the -Djava. endorsed. dirs), then click Apply.


2 Answers

From the documentation of Endorsed Standards Override Mechanism, it is a mechanism to provide newer versions of an endorsed standard than those included in the Java 2 Platform

Your project must be creating and/or using such an implementation.

By specifying <endorseddirs> attribute, you are instructing the java compiler to look at jars present in this folder to override similarly defined classes in the standard jdk.

like image 52
Raghuram Avatar answered Sep 22 '22 18:09

Raghuram


By Java documentation, java.endorsed.dirs is used to provide an Endorsed Standards Override Mechanism. 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.

The packages that can be overriden this way are grouped into Endorsed Standards APIs and Standalone Technologies, and are listed in the Java documentation.

Roughly speaking the Endorsed Standards APIs include:

  • javax.rmi.CORBA
  • various org.omg.* packages
  • org.w3c.dom
  • various org.xml.sax.* packages

Standalone Technologies include:

  • Java API for XML Processing (JAXP), version 1.4
  • Java Architecture for XML Binding (JAXB), version 2.0
  • Java API for XML-Based Web Services (JAX-WS), version 2.0
  • Java Compiler API, version 1.0
  • Pluggable Annotation Processing API, version 1.0
  • Common Annotations for the Java Platform, version 1.0
  • Scripting for the Java Platform, version 1.0
  • SOAP with Attachments API for Java (SAAJ), version 1.3
like image 38
amitmula Avatar answered Sep 19 '22 18:09

amitmula