JAX-RS Example JerseyWe can create JAX-RS example by jersey implementation. To do so, you need to load jersey jar files or use maven framework. In this example, we are using jersey jar files for using jersey example for JAX-RS. Click me to download jersey jar files. There are created 4 files for hello world JAX-RS example:
The first 3 files are created for server side and 1 application for client side. JAX-RS Server CodeFile: Hello.java File: web.xml File: index.html Now run this application on server. Here we are using Tomcat server on port 4444. The project name is restfuljersey. After running the project, you will see the following output: JAX-RS Client CodeThe ClientTest.java file is created inside the server application. But you can run client code by other application also by having service interface and jersey jar file. File: ClientTest.java Output: Hello Jersey Plain <?xml version="1.0"?><hello> Hello Jersey</hello> <html> <title>Hello Jersey</title><body><h1>Hello Jersey HTML</h1></body></html> Click me to download JAX-RS example using eclipse without jersey jar files. Next TopicJAX-RS Annotations Example |