You are looking for Class#forNameand Class#newInstance.
This link serves as a good example of class initialization, knowing its name (extracted from the link):
Class c = Class.forName("com.xyzws.AClass");
AClass a = (AClass)c.newInstance();
A good example for these situations is to use JDBC (as the link indicates), because you are initializing the db engine driver object that you want to connect. Remember that this driver comes from the imported bank into your project, it can be a bank for MySQL, Oracle or MSSQL Server, you just provide the driver class name and allow the JDBC API and the bank to process SQL work.
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection(url, "myLogin", "myPassword");
In addition, for this specific task, when loading a jar, questions and answers dynamically arise:
source
share