Add a few null checks, it is possible that the workstation does not have an active window, but it is also impossible for PlatformUI.getWorkbench to throw an IllegalStateException if the desktop is not already running (for example, createAndRunWorkbench () has not yet been called).
IWorkbenchWindow window = PlatformUI.getWorkbench().getInstance() .getActiveWorkbenchWindow(); if(workbenchWindow != null) { IWorkbenchPage page = window .getActivePage(); }
Rich seller
source share