Reputation: 41
I am working on Eclipse IDE and creating a web-service program. IDE gives an error while importing
import javax.jws.WebService;
import javax.jws.WebMethod;
error shows the import javax.jws can not be resolved
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService
public class Hello {
private final String message = "Hello, ";
public Hello() {
}
@WebMethod
public String sayHello(String name) {
return message + name + ".";
}
}
Upvotes: 4
Views: 14631
Reputation: 41
in the pom.xml file add
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
Upvotes: 2
Reputation: 1032
Use javax.jws-api
artifact instead and it will solve your problem. Below is the gradle implementation:
implementation 'javax.jws:javax.jws-api:1.1'
Check the version and use the latest.
It is not recommended to downgrade the Java version just to fix the issue.
Upvotes: 1
Reputation: 8383
Check that your project has appropriate JDK.
Right click on the project --> Properties --> Compiler
I created your file in Java8, and it worked.
Upvotes: 3