0

I have several SDK's which, when installed on Windows, create a folder in C://Program Files//SDK Name//folders and files.

I have a switch case in main method of the setup class where, based on the string input which provides SDK name, I need to load/reference the corresponding dlls and jars for that SDK from the installation location as specified above.

Since these dlls and jars can change with every new SDK build, I want these to be picked from the specified installed location instead of including them in my project.

Can you please let me know how this can be done in JAVA (Windows 10, netbeans 11, jdk 13). I tried the below approaches but not its not working:

Inside the main method of the set up class:

switch (sdkName.toLowerCase()) {
    case "A": {
        A sdkA= new A();
        //Class for each SDK. How to Load dlls and jars from this class or within this case statement ?
        System.load("above path to native library/dll") //Doesn't WORK gives java.lang.unsatisfiedLink error
        break;
    }
    case "B": {
        B sdkB= new B();
        break;
    }
    case "C":{
        C sdkC= new C();
        break;
    }
}

I tried to use maven and added the following in the pom.xml. Compiles but in run time I get NoClassDefFound and not sure if this is the right way to go about it since I would still have to do this for all jars and dlls in all the sdk.

<dependency>
    <groupId>com.crossmatch.biobase</groupId>
    <artifactId>BioBase</artifactId>
    <type>jar</type>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>C:\\Program Files\\Crossmatch\\SDKA\\Lib\\a.jar</systemPath>
</dependency>

Tried to pass the jar files via classpath from the project folder and from the target folder:

java -cp "C:\Program Files\SDK\a.jar,MyApp-1.0-SNAPSHOT.jar" com.company.classNamewiwthMainMethodSetUpClass xmlFileThatReadsTheSDKNameandOTherSDKSpecificData

Here I get the error:

Could not find or load main class.. ClassNotFoundException

ItsPete
  • 2,363
  • 3
  • 27
  • 35
codingAid
  • 1
  • 1

0 Answers0