Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Seems like javax.activation package is deprecated in Java 9. Oracle migration guide proposes to use --add-modules java.activation option during JVM start.

However, I would like to avoid this and replace javax.activation package's classes, as it is deprecated and will be removed in future java versions. I suppose, there should be some kind of alternative for javax.activation. If there is any available, what is it?

like image 783
Dmitriy Dumanskiy Avatar asked Sep 29 '17 16:09

Dmitriy Dumanskiy


People also ask

What is javax activation?

javax.activation. javax.xml.bind.attachment. This package is implemented by a MIME-based package processor that enables the interpretation and creation of optimized binary data within an MIME-based package format.

What is Jakarta activation API?

Within computing, Jakarta Activation (JAF; formerly JavaBeans Activation Framework) is a Jakarta EE API that enables developers to: determine the type of an arbitrary piece of data, encapsulate access to it, discover the operations available on it and. to instantiate the appropriate bean to perform the operation(s).


2 Answers

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" /> 
like image 148
Naman Avatar answered Sep 19 '22 15:09

Naman


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 use requires java.activation.

like image 20
Alan Bateman Avatar answered Sep 20 '22 15:09

Alan Bateman