
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
How can we create a Service Provider interface in Java 9?
A module that provides the implementation for the Service interface contains a "provides" statement in the module descriptor file. If the module doesn’t have the "provides" statement in the module descriptor file, the service loader can't load that module.
We can create the Service Provider Interface by using below steps:
- We create a new Module com.tutorialspoint.serviceproviderinterface.
- In the src/main/java directory, we create "module-info.java" file.
- Inside our source directory, we create the package com.tutorialspoint.serviceproviderinterface.spi.
- Finally, we create the interface ServiceProviderInterface that contains a method: printServiceName() to be implemented.
In the below, we can define Service Provider Interface.
package com.tutorialspoint.serviceproviderinterface.spi; public interface ServiceProviderInterface { void printServiceName(); }
- Related Articles
- How can we implement the Subscriber interface in Java 9?
- Can we use private methods in an interface in Java 9?
- Can we create an object for an interface in java?
- How can we create an unmodifiable Set in Java 9?
- How can we create an unmodifiable List in Java 9?
- Can we create non static variables in an interface using java?
- How can we create an unmodifiable Map in Java 9?\n
- How can we create an instance of VarHandle in Java 9?
- Can we declare an interface with in another interface in java?
- How can we create a multi-release jar(mrjar) using jar tool in Java 9?
- Can we have a private method or private static method in an interface in Java 9?\n
- Can we define a class inside a Java interface?
- Can we define an interface inside a Java class?
- How can we create a custom exception in Java?
- How can we implement a map in JShell in Java 9?

Advertisements