What is the replacement for javax.activation package in java 9?

橙三吉。 提交于 2019-11-26 16:15:51
Naman

JavaBeans Activation Framework (JAF) is possibly the alternative you are looking for to the existing package.

This standalone release of JAF uses a Java Platform Module System automatic module name of java.activation, to match the module name used in JDK 9. A future version will include full module metadata.

The standalone APIs are supported in modular form only, via the concept of upgradeable modules. Using them, it's possible to use a version of that module from a later release in any phase, i.e., at compile time, build time, or runtime.


The currently available version for this is 1.2.0 which can be used like this:

Maven

<dependency>
    <groupId>com.sun.activation</groupId>
    <artifactId>javax.activation</artifactId>
    <version>1.2.0</version>
</dependency>

Gradle

compile 'com.sun.activation:javax.activation:1.2.0'

Ivy

<dependency org="com.sun.activation" name="javax.activation" rev="1.2.0" />

The JavaBeans Activiation Framework is a standalone technology with its own maintenance JSR in the JCP and its own download. Yes, Java SE 9 has deprecated it and has proposes to remove in a future release along with the modules shared with Java EE but this doesn't impact the standalone version. The standalone version will live on. If you are using Maven then this should work:

<dependency>
  <groupId>com.sun.activation</groupId>
  <artifactId>javax.activation</artifactId>
  <version>1.2.0</version>
</dependency>

and if you are developing a module then you can requires java.activation.

As written above, java versions > 8 are not providing javax.activation. I met this exception when working on camel project. I've just added the following dependency:

<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!