org.eclipse.ui.jarpackager 패키지는 프로그래밍하여 파일을 Jar 파일로 내보내는 유틸리티를 제공합니다. 다음은 JarPackageData 클래스의 사용을 대략적으로 설명하는 코드 스니펫입니다.
void createJar(IType mainType, IFile[] filestoExport) { Shell parentShell= ...; JarPackageData description= new JarPackageData(); IPath location= new Path("C:/tmp/myjar.jar"); description.setJarLocation(location); description.setSaveManifest(true); description.setManifestMainClass(mainType); description.setElements(filestoExport); IJarExportRunnable runnable= description.createJarExportRunnable(parentShell); try { new ProgressMonitorDialog(parentShell).run(true,true, runnable); } catch (InvocationTargetException e) { // An error has occurred while executing the operation } catch (InterruptedException e) { // operation has been canceled. } }
JarPackageData의 플러그인 특정 서브클래스를 작성하기 위한 추가 API가 제공됩니다. 이 API를 사용하여 다른 플러그인은 자신의 Jar 내보내기/가져오기 마법사를 구현하고 JarPackageData 오브젝트의 컨텐츠를 해당 Jar 설명 파일에 저장할 수 있습니다.
JAR이 JarPackageData를 통해 설명되면 JarWriter2를 사용하여 프로그래밍적으로 작성할 수 있습니다.