35

I'm trying to get into JAX-RS. My project jdk is set to 1.7.03. Does there have to be definitions of annotations for JAX-RS(javax.ws.rs)? If not, where I can find them?

Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
narek.gevorgyan
  • 4,165
  • 5
  • 32
  • 52

3 Answers3

39

These classes (JSR 311: JAX-RS: The JavaTM API for RESTful Web Services) are not part of the JDK. You need to include appropriate JAR file to your CLASSPATH. You can find the API e.g. in maven repository.

Also check out , (reference implementation), from JBoss, and few other JAX-RS implementations.

JohnK
  • 6,865
  • 8
  • 49
  • 75
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
  • 3
    If they're not part of the JDK, then why are the classes defined in the Java JDK? See http://docs.oracle.com/javaee/6/api/javax/ws/rs/Path.html – David Brossard Feb 05 '14 at 20:29
  • 6
    Because they are part of the JavaEE specification and not part of the base Java SDK. – Kolban Sep 06 '14 at 15:08
  • Jersey 2.25.1 includes `javax.ws.rs-api-2.0.1.jar`, which contains the classes that you need. You can download the `Jersey JAX-RS 2.0 RI bundle` from https://jersey.java.net/download.html. – james.garriss Apr 26 '17 at 18:14
12

Try: http://download.oracle.com/otndocs/jcp/jaxrs-2_0_rev_A-mrel-spec/index.html

Download: javax.ws.rs-api-2.0.rev.A.jar

Then add to your Project Properties(YourProjectName)->Libraries->Add JAR/Folder

orientchen1978
  • 190
  • 1
  • 6
  • 3
    Better late than never. Maven rep points to `JSR 311` and today we are at `JSR 339-JAX-RS-2.0` – Tirath Apr 17 '16 at 07:32
6

It doesn't matter what your JDK is set to.

Go here= http://www.java2s.com/Code/Jar/j/Downloadjavaxwsrsjar.htm

Or type in "Download javax.ws.rs" into Google.

Download “javax.ws/javax.ws.rs.jar.zip”

enter image description here

Unzip to your desktop. The resulting file should be a jar file. Open your project preferences and add it as external jar.

enter image description here

enter image description here

Select your javax.ws.rs.jar file from your Desktop.

Click “Apply” and then “OK”.

Now you should be able to use the javax.ws.rs libraries. You can test it by typing "import javax.ws.rs.GET;" in one of your Java classes.

buildingKofi
  • 60
  • 1
  • 2
  • 9
Gene
  • 10,819
  • 1
  • 66
  • 58