code: public static Credentials getCredentialFromPrivateKeyServiceAccount(
        String serviceAccountEmail, String privateKeyFile)
        throws IOException, GeneralSecurityException {
  
      PrivateKey privateKey =
          SecurityUtils.loadPrivateKeyFromKeyStore(SecurityUtils.getPkcs12KeyStore(),
              new FileInputStream(privateKeyFile), "notasecret", "privatekey", "notasecret");
  
      return ServiceAccountJwtAccessCredentials.newBuilder()
          .setClientEmail(serviceAccountEmail)
          .setPrivateKey(privateKey)
          .build();
    }
docs: Initializes OAuth2 credential from a private keyfile, as described in
  <a href="https://developers.google.com/api-client-library/java/google-api-java-client/oauth2#service_accounts"
  >Service accounts</a>.
  
  @param serviceAccountEmail Email address of the service account associated with the keyfile.
  @param privateKeyFile Full local path to private keyfile.
  @return a {@link com.google.auth.Credentials} object.
  @throws java.io.IOException if any.
  @throws java.security.GeneralSecurityException if any.