Instantiate an application
Pre-requisites
Before instantiating your app with MSAL4J:
- Understand the types of Client applications available- Public Client and Confidential Client applications.
- You'll need to register the application with Microsoft Entra ID. You will therefore know:
- Its clientID(a string representing a GUID)
- The identity provider URL (named the instance) and the sign-in audience for your application. These two parameters are collectively known as the authority.
- Possibly the TenantIDin the case you are writing a line of business application (just for your organization, also named single-tenant application)
- In case it's a confidential client app, its application secret (clientSecretstring) or certificate
- For web apps, you'll have also set the redirectUriwhere the identity provider will contact back your application with the security tokens.
 
- Its 
Instantiate a Public Client application
String PUBLIC_CLIENT_ID;
String AUTHORITY;
PublicClientApplication app = 
    PublicClientApplication
        .builder(PUBLIC_CLIENT_ID)
        .authority(AUTHORITY)
        .build();
Instantiate a Confidential Client application
You will need either a secret or a certificate, as described in Client Credentials.
If you have a secret:
String PUBLIC_CLIENT_ID;
String AUTHORITY;
String CLIENT_SECRET;
IClientCredential credential = ClientCredentialFactory.createFromSecret(CLIENT_SECRET);
ConfidentialClientApplication app = 
    ConfidentialClientApplication
        .builder(PUBLIC_CLIENT_ID, credential)
        .authority(AUTHORITY)
        .build();
If you have a certificate:
String PUBLIC_CLIENT_ID;
String AUTHORITY;
PrivateKey PRIVATE_KEY;  
X509Certificate PUBLIC_KEY;
IClientCredential credential = ClientCredentialFactory.createFromCertificate(PRIVATE_KEY, PUBLIC_KEY);
ConfidentialClientApplication app = 
    ConfidentialClientApplication
        .builder(PUBLIC_CLIENT_ID, credential)
        .authority(AUTHORITY)
        .build();