private Library getOrCreateExternalLibrary(String libraryName, String libraryProgramPathname)
			throws InvalidInputException {
		if (libraryName == null) {
			return null;
		}
		ExternalManager externalManager = program.getExternalManager();
		SymbolTable symbolTable = program.getSymbolTable();
		Symbol s = symbolTable.getLibrarySymbol(libraryName);
		Library library;
		if (s != null) {
			library = (Library) s.getObject();
		}
		else {
			try {
				library =
					externalManager.addExternalLibraryName(libraryName, SourceType.USER_DEFINED);
			}
			catch (DuplicateNameException e) {
				String message = e.getMessage();
				if (message == null) {
					message = "";
				}
				showInputErr("Couldn't create external library name. " + message);
				restoreLibraryName();
				selectLibraryName();
				return null;
			}
		}
		if (libraryProgramPathname != null && libraryProgramPathname.length() > 0) {
			externalManager.setExternalPath(libraryName, libraryProgramPathname, true);
		}
		return library;
	}
Pop up the data tree dialog so the user can choose the external program.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symboltree/EditExternalLocationPanel.java