Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Check dependencies on libraries



To check if a jar file depends on other jar files, you must create a JarDependencies, and then use one of the several methods which allow to check if this library depends on other libraries, the Swing or JavaFX framerwork, or several packages.

Check dependencies on another library

To check the dependency of your jar file on another jar file, you lmsut create associated JarDependencies and use one of the following methods: For example:
   JarDependencies depend = new JarDependencies(<myJarFile>);
   JarDependencies anotherDepend = new JarDependencies(<aSecondJarFile>);
   boolean isDependingOn = depend.isDependingOn(anotherDepend);

Excluding classes

It is possible to exclude classes from the check by using the following method:

Check dependencies on a set of packages

Main Article: DependencyChecker

The DependencyChecker check if a Jar file or a JarDependencies has dependencies to a set of packages.

For example:
   Set<String> set = new HashSet<>();
   set.add("java.util");
   DependencyChecker checker = new DependencyChecker();
   boolean dependsOn = checker.check(<myJarFile>, set);

Check dependencies on Swing or JavaFX

To check the dependency of your jar file on Swing or JavaFX, use: For example:
   JarDependencies depend = new JarDependencies(<myJarFile>);
   boolean isDependingOnSwing = DependencyUtilities.dependOnSwing(depend);
   boolean isDependingOnJavaFX = DependencyUtilities.dependOnJavaFX(depend);

Excluding classes

It is possible to exclude classes from the check by using one of the following methods: For example:
   JarDependencies depend = new JarDependencies(<myJarFile>);
   Set<String> set = new HashSet<>
   set.add("java.awt.geom.Arc2D");
   set.add("java.awt.geom.Ellipse2D");      
   boolean isDependingOnSwing = DependencyUtilities.dependOnSwing(depend, set);

See also


Categories: General

Copyright 2019 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 licence