JavaModelManager manager = JavaModelManager.getJavaModelManager();
SubProgressMonitor subMonitor = null;
try {
if (monitor != null) {
subMonitor = new SubProgressMonitor(monitor, 50); // 50% of the time is spent in initializing containers and variables
subMonitor.beginTask("", 100); //$NON-NLS-1$
subMonitor.worked(5); // give feedback to the user that something is happening
manager.batchContainerInitializationsProgress.initializeAfterLoadMonitor.set(subMonitor);
}
if (manager.forceBatchInitializations(true/*initAfterLoad*/)) { // if no other thread has started the batch container initializations
manager.getClasspathContainer(Path.EMPTY, null); // force the batch initialization