Java Deprecated API Scanner tool (jdepscan) in Java 9 with Examples

Java Deprecated API Scanner tool: Java Deprecated API Scanner tool i.e. jdeprscan is a static analyzing command-line tool which is introduced in JDK 9 for find out the uses of deprecated API in the given input. Here the input can be .class file name, directory or JAR file. Whenever we provide any input to jdeprscan command line tool then it generates the dependencies to the system console. jdeprscan introduced with various options which affect the output. As per option, jdeprscan command-line tool generates the output. jdeprscan tool identifies the deprecated APIs which defined by Java SE Deprecated APIs but it will not list out the deprecated APIs which is used by third-party libraries.

Syntax for using jdeprscan tool:

jdeprscan [options] {class|dir|jar}

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Program to illustrate the output of jdeprscan tool
  
import java.awt.*;
class Geeks extends Thread {
    public void run()
    {
        System.out.println("Child Thread");
    }
  
    public static void main(String args[])
    {
        Thread thread = new Thread();
        thread.start();
        thread.stop();
  
        List list = new List();
        list.addItem("Geeksforgeeks");
  
        Integer i = new Integer(100);
        System.out.println(i);
    }
}

chevron_right


Compile Time Console:

Note: Geeks.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.



Output:

jdeprscan Geeks.class

Various options available for jdeprscan:

  1. –release 6|7|8|9: It will list out the uses of deprecated APIs in the given argument as per given release. Suppose we are using JDK 9 and we want to list out the deprecated APIs as per Java release 7, then we can use this option.

    Output:

    jdeprscan --release 6  Geeks.class

    jdeprscan --release 7  Geeks.class

  2. –verbose: It will enable printing of additional message during listing out deprecated APIs.

    Output:

    jdeprscan --verbose Geeks.class

  3. –version: It will specify the version of jdeprscan.

    Output:

    jdeprscan --version
    9.0.4
    

  4. –full-version: It will print the version of the jdeprscan tool.

    Output:

    jdeprscan --full-version
    9.0.4+11
    

  5. –help: It will display the help message for user. Instead of using -help, we can use -h also.

    Output:

    jdeprscan --help

  6. –list: It will list out the deprecated APIs. Instead of using -list, we can use -l also.

    Output:

    jdeprscan --list

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.




My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.