Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add javax.annotation.Generated to Java SE 5?

I'm working on a project that has to run on Java SE 5 and Java SE 6. I recently started using a tool that adds @Generated annotations to generated code, and I want to keep those annotations. It looks like javax.annotation.Generated is in Java 5 EE and Java 6 SE and later, but is not in the Java 5 SE API.

What's the best way to include javax.annotation.Generated when I send it to the customer, so it will run on both Java SE 5 and Java SE 6 without any problems? Do I just need to include an extra jarfile? If so, which one does @Generated live in?

like image 973
rob Avatar asked Feb 22 '12 22:02

rob


2 Answers

You can get javax.annotation.Generated, along with various other classes from that package, from the Maven central repo at this location. You can just download the JARs, you don't need to use Maven to get them.

Answer courtesy of GrepCode.

like image 179
skaffman Avatar answered Sep 19 '22 12:09

skaffman


According to javax.annotation.Generated javadoc, its retention is Source, so the annotation won't be compiled to your classes (and result classes with and without this annotation are the same). So your customers never need any jar file containing this annotation, as long as you distribute compiled classes.

like image 35
Amir Pashazadeh Avatar answered Sep 20 '22 12:09

Amir Pashazadeh