I am learning RESTful Web Services and all the tutorials use javax.ws.rs.*
package. But with JDK 6 and JDK 7, my Eclipse doesn't seem to recognize javax.ws
package. What am I missing here?
Asked
Active
Viewed 1.6k times
9

Ihor Patsian
- 1,288
- 2
- 15
- 25

user238021
- 1,181
- 8
- 30
- 44
-
Do you have jsr311-api.jar in your classpath? – tenorsax Apr 04 '12 at 03:25
-
Adding jsr311-api.jar fixed the issue. But the java 6 API mentions these classes. Not sure why I need to add it separately. – user238021 Apr 04 '12 at 06:03
2 Answers
2
You're may be missing Jersey installation, or something in your environment configuration. Try also installing Eclipse WPT. You can follow this tutorial, it covers prerequisites and basic installation procedures as well.

tenorsax
- 21,123
- 9
- 60
- 107
-
I added jersey installation to classpath. But Jersey does not have javax.ws.rs package. shouldn't javax.ws.rs package be in Java 6 SDK? But it doesn't seem to be. – user238021 Apr 04 '12 at 06:00
2
javax.ws.rs is not a JDK package; it is a server-side API that forms part of the Java EE specification. You would need to include a Java EE runtime on your classpath or source an implementation from a 3rd party if you're going the self-assembly route (e.g. using Tomcat.)

McDowell
- 107,573
- 31
- 204
- 267
-
1Why is jax-ws (Soap based) shipped with JDK but not jax-rs (Rest based)? – Abidi Feb 18 '14 at 16:14
-
@Abidi I guess it is because it is much easier to write a REST client than a SOAP client but I can't give a definitive answer. – McDowell Feb 18 '14 at 16:34
-
Interesting, jax-rs does come with Metro stack and Metro is shipped with JDK6. This means not full stack of Metro is shipped with JDK. Confused! – Abidi Feb 18 '14 at 16:43
-
1@Abidi I do not think [Metro](https://metro.java.net/discover/faq.html#components) is a JAX-RS implementation. I believe [Jersey](https://jersey.java.net/) is the JAX-RS reference implementation. – McDowell Feb 18 '14 at 16:53