Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is javax.annotation

Ok, so this is probably a NooB question (I'm more of a C++ guy), but I'm lost in the java woods and its frameworks forests...

I'm trying to look into eclipse RCP development. For that I'm following this well-known tutorial: http://www.vogella.com/tutorials/EclipseRCP/article.html

At step 15 I need to add the following dependency packages to import in my bundle. javax.annotation javax.injection

The problem is that I cannot select these (they are not in the selection list) I do have javax.el javax.servlet.* and javax.xml.*

Looking at http://docs.oracle.com/javase/7/docs/api/overview-summary.html suggests that this should be part of the standard java.

What obvious mistake am I missing?

like image 980
Respect2All Avatar asked Mar 23 '14 09:03

Respect2All


People also ask

What are Javax annotations?

Description. Generated. The Generated annotation is used to mark source code that has been generated. PostConstruct. The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization.

What is javax annotation resource?

The javax. annotation. Resource annotation is used to declare a reference to a resource; @Resource can decorate a class, a field, or a method.

What is javax annotation API used for?

This class is used to allow multiple resources declarations.

What is javax annotation generated?

The Generated annotation is used to mark source code that has been generated. It can also be used to differentiate user written code from generated code in a single file. When used, the value element must have the name of the code generator.


2 Answers

The dependency including version:

<dependency>     <groupId>javax.annotation</groupId>     <artifactId>javax.annotation-api</artifactId>     <version>1.3.2</version> </dependency> 

See: http://mvnrepository.com/artifact/javax.annotation/javax.annotation-api

Or for the newerjakarta.annotation:

<dependency>    <groupId>jakarta.annotation</groupId>    <artifactId>jakarta.annotation-api</artifactId>    <version>1.3.5</version> </dependency> 

See: https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api

The Java Common Annotations Module java.xml.ws.annotation was deprecated in Java version 9 and was removed in java version 11. If this leads to a problem you could try to add javax.annotation.

The Javadocs for Java 8 can be found here: http://docs.oracle.com/javase/8/docs/api/javax/annotation/package-summary.html

like image 129
Stefan Großmann Avatar answered Sep 29 '22 15:09

Stefan Großmann


Your comment indicates this is for Guava, so you want the JSR305 library, which extends the javax package.

2020 Update: Note that this library breaks the Oracle licensing agreement and Guava has since moved to checkerframework's Nullable annotation.

like image 36
Alice Purcell Avatar answered Sep 29 '22 16:09

Alice Purcell