//obtain the active page
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
returns Exception in thread "Thread-3" java.lang.NullPointerExceptionµ. What shall i do?
//obtain the active page
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
returns Exception in thread "Thread-3" java.lang.NullPointerExceptionµ. What shall i do?
Add some null checks, it is possible for the workbench to not have an active window, not it is also possible for PlatformUI.getWorkbench to throw an IllegalStateException if the workbench is not yet started (e.g createAndRunWorkbench() has not yet been called).
IWorkbenchWindow window = PlatformUI.getWorkbench().getInstance()
.getActiveWorkbenchWindow();
if(workbenchWindow != null) {
IWorkbenchPage page = window .getActivePage();
}