private Program getProgram() {

		ProgramManager pm = tool.getService(ProgramManager.class);
		if (pm != null) {
			return pm.getCurrentProgram();
		}
		return null;
    }
Get the currently open program using the ProgramManager service.
Ghidra/Extensions/sample/src/main/java/ghidra/examples/HelloProgramPlugin.java