How to get vendor name and version of libraries used in java project through java program

288 Views Asked by At

I am able to get library list used in my java project using J Depend using simple java program as bellow,

import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import jdepend.framework.*;
//import junit.framework.TestCase;

public class ConstraintTest {
    private JDepend jdepend;
    public static void main(String[] args) {
        JDepend jdepend = new JDepend();

        try{
            jdepend.addDirectory("C:/abc-workspace/example");
                jdepend.analyze();
                Collection collection=jdepend.getPackages();
                for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
                JavaPackage type = (JavaPackage) iterator.next();
                System.out.println(type.getName());
            }
        }catch(IOException e){
            e.printStackTrace();
        }  
    }  
}

out put for above program i.e for "example" project.

java.util
java.io
jdepend.framework
java.lang
com.example

Now my task is to find Vendor name and the version number for above libraries. Is it possible to get these information from J Depend?.

0

There are 0 best solutions below