Adding a template to a new document specification through the Java API

Before adding templates to a document specification, perform a IBM Engineering Lifecycle Optimization - Publishing API initialization. For more information, see Initializing and preparing the Java API.
DocumentSpecificationBuilder builder = new DocumentSpecificationBuilder();
URI configURI = new File( AppUtils.getConfigFilePath()).toURI();
RPEDocumentSpecification docSpec = builder.create(configURI.toString());
			
RPETemplate template = builder.loadTemplate( configURI.toString(), new
File(c:\\test\\sample.dta).getAbsolutePath());

docSpec.getRuntime().addTemplate( template);