Package utils

Class JarLibraryLoader<T>

java.lang.Object
utils.JarLibraryLoader<T>
Type Parameters:
T - Library defined interface

public class JarLibraryLoader<T> extends Object
Utility library to permit the loading of a library in a JAR. ...
Since:
13/08/2023
Author:
Killian Monier and Nidhal Mareghni
  • Field Details

    • libraryClass

      private final Class<T> libraryClass
    • libraryName

      private final String libraryName
    • projectPath

      private final String projectPath
  • Constructor Details

    • JarLibraryLoader

      public JarLibraryLoader(Class<T> libraryClass, String libraryName)
      Constructor of this class.
      Parameters:
      libraryClass - Class of the library defined interface
      libraryName - Name of the library
  • Method Details

    • create

      public static <T> JarLibraryLoader<T> create(Class<T> libraryClass, String libraryName)
      Create a new instance of JarLibraryLoader
      Type Parameters:
      T - Library defined interface
      Parameters:
      libraryClass - Class of the library defined interface
      libraryName - Name of the library
      Returns:
      New instance of JarLibraryLoader
    • copyFileFromJar

      public static void copyFileFromJar(String resourcePath, String destinationPath) throws IOException
      Copies a file from the JAR resources to a specified destination on the local file system.
      Parameters:
      resourcePath - The path of the file within the JAR resources to copy.
      destinationPath - The path of the destination where the file will be copied to.
      Throws:
      IOException - If an I/O error occurs during the copying process.
      FileNotFoundException - If the specified resource path cannot be found in the JAR resources.
    • getOSName

      public static String getOSName()
      Retrieves the name of the operating system on which the Java program is running.
      Returns:
      The name of the operating system (e.g., "Windows", "Linux", "macOS").
    • getLibraryInstance

      public T getLibraryInstance()
      Provide the library instance.
      Returns:
      The library instance