

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Provider getVersion() method in Java
The version number of the provider can be obtained using the method getVersion() in the class java.security.Provider. This method requires no parameter and it returns the version number of the provider as required.
A program that demonstrates this is given as follows −
Example
import java.security.*; import java.util.*; public class Demo { public static void main(String[] argv) { try { KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("DSA"); Provider p = kpGenerator.getProvider(); System.out.println("The version number is: " + p.getVersion()); } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } } }
Output
The version number is: 1.8
Now let us understand the above program.
The getVersion() method is used to get the version number of the provider. Then this version number is displayed. If the algorithm name is wrong, then the exception NoSuchAlgorithmException is thrown. A code snippet that demonstrates is given as follows −
try { KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("DSA"); Provider p = kpGenerator.getProvider(); System.out.println("The version number is: " + p.getVersion()); } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); }
- Related Questions & Answers
- Provider elements() method in Java
- Provider entrySet() method in Java
- Provider keys() method in Java
- Provider keySet() method in Java
- Provider values() method in Java
- Provider get() method in Java
- Provider getInfo() method in Java
- Provider getName() method in Java
- Provider toString() method in Java
- Provider getProperty() method in Java
- Provider getService() method in Java
- How can we create a Service Provider interface in Java 9?
- Using MDX provider in SAP HANA
- What are extender provider components in C#?
- Who is the best VoIP provider in the USA?
Advertisements