org.eclipse.jdt.launching.LibraryLocation Java Examples
The following examples show how to use
org.eclipse.jdt.launching.LibraryLocation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeInfoViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processVMInstallType(IVMInstallType installType, List locations, List labels) { if (installType != null) { IVMInstall[] installs= installType.getVMInstalls(); boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$ for (int i= 0; i < installs.length; i++) { String label= getFormattedLabel(installs[i].getName()); LibraryLocation[] libLocations= installs[i].getLibraryLocations(); if (libLocations != null) { processLibraryLocation(libLocations, label); } else { String filePath= installs[i].getInstallLocation().getAbsolutePath(); // on MacOS X install locations end in an additional "/Home" segment; remove it if (isMac && filePath.endsWith(HOME_SUFFIX)) filePath= filePath.substring(0, filePath.length()- HOME_SUFFIX.length() + 1); locations.add(filePath); labels.add(label); } } } }
Example #2
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processVMInstallType(IVMInstallType installType, List<IPath> locations, List<String> labels) { if (installType != null) { IVMInstall[] installs= installType.getVMInstalls(); boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); for (int i= 0; i < installs.length; i++) { String label= getFormattedLabel(installs[i].getName()); LibraryLocation[] libLocations= installs[i].getLibraryLocations(); if (libLocations != null) { processLibraryLocation(libLocations, label); } else { IPath filePath= Path.fromOSString(installs[i].getInstallLocation().getAbsolutePath()); // On MacOS X, install locations end in an additional "/Home" segment; remove it. if (isMac && "Home".equals(filePath.lastSegment())) //$NON-NLS-1$ filePath= filePath.removeLastSegments(1); locations.add(filePath); labels.add(label); } } } }
Example #3
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processVMInstallType(IVMInstallType installType, List<String> locations, List<String> labels) { if (installType != null) { IVMInstall[] installs= installType.getVMInstalls(); boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$ for (int i= 0; i < installs.length; i++) { String label= getFormattedLabel(installs[i].getName()); LibraryLocation[] libLocations= installs[i].getLibraryLocations(); if (libLocations != null) { processLibraryLocation(libLocations, label); } else { String filePath= installs[i].getInstallLocation().getAbsolutePath(); // on MacOS X install locations end in an additional // "/Home" segment; remove it if (isMac && filePath.endsWith(HOME_SUFFIX)) filePath= filePath.substring(0, filePath.length() - HOME_SUFFIX.length() + 1); locations.add(filePath); labels.add(label); } } } }
Example #4
Source File: RuntimeUtils.java From JReFrameworker with MIT License | 5 votes |
public static boolean isRuntimeJar(File jar) throws IOException { IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall); for (LibraryLocation library : locations) { File runtime = JavaCore.newLibraryEntry(library.getSystemLibraryPath(), null, null).getPath().toFile().getCanonicalFile(); if(runtime.equals(jar.getCanonicalFile())){ return true; } } return false; }
Example #5
Source File: RuntimeUtils.java From JReFrameworker with MIT License | 5 votes |
public static File getRuntimeJar(String jarName) throws IOException { IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall); for (LibraryLocation library : locations) { File runtime = JavaCore.newLibraryEntry(library.getSystemLibraryPath(), null, null).getPath().toFile().getCanonicalFile(); if(runtime.getName().equals(jarName)){ return runtime; } } return null; }
Example #6
Source File: StandardSREInstallTest.java From sarl with Apache License 2.0 | 5 votes |
@Test public void getClassPathEntry() { List<IRuntimeClasspathEntry> locations = new ArrayList<>(); LibraryLocation location = new LibraryLocation(this.path, Path.EMPTY, Path.EMPTY); IClasspathEntry cpEntry = JavaCore.newLibraryEntry( location.getSystemLibraryPath(), location.getSystemLibrarySourcePath(), location.getPackageRootPath()); IRuntimeClasspathEntry rtcpEntry = new RuntimeClasspathEntry(cpEntry); rtcpEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES); locations.add(rtcpEntry); assertEquals(locations, this.sre.getClassPathEntries()); }
Example #7
Source File: TestUtils.java From CogniCrypt with Eclipse Public License 2.0 | 4 votes |
/** * This method creates a empty JavaProject in the current workspace * * @param projectName for the JavaProject * @return new created JavaProject * @throws CoreException */ public static IJavaProject createJavaProject(final String projectName) throws CoreException { final IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot(); deleteProject(workSpaceRoot.getProject(projectName)); final IProject project = workSpaceRoot.getProject(projectName); project.create(null); project.open(null); final IProjectDescription description = project.getDescription(); description.setNatureIds(new String[] {JavaCore.NATURE_ID}); project.setDescription(description, null); final IJavaProject javaProject = JavaCore.create(project); final IFolder binFolder = project.getFolder("bin"); binFolder.create(false, true, null); javaProject.setOutputLocation(binFolder.getFullPath(), null); final List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); final IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); final LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall); for (final LibraryLocation element : locations) { entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null)); } // add libs to project class path javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); final IFolder sourceFolder = project.getFolder("src"); sourceFolder.create(false, true, null); final IPackageFragmentRoot packageRoot = javaProject.getPackageFragmentRoot(sourceFolder); final IClasspathEntry[] oldEntries = javaProject.getRawClasspath(); final IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1]; System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length); newEntries[oldEntries.length] = JavaCore.newSourceEntry(packageRoot.getPath()); javaProject.setRawClasspath(newEntries, null); return javaProject; }
Example #8
Source File: TestVMType.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override public LibraryLocation[] getDefaultLibraryLocations(File installLocation) { // for now use the same stub JAR for all IPath path = Path.fromOSString(new File(installLocation, RTSTUBS_JAR).getAbsolutePath()); return new LibraryLocation[] { new LibraryLocation(path, Path.EMPTY, Path.EMPTY) }; }
Example #9
Source File: TypeInfoViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void processLibraryLocation(LibraryLocation[] libLocations, String label) { for (int l= 0; l < libLocations.length; l++) { LibraryLocation location= libLocations[l]; fLib2Name.put(location.getSystemLibraryPath().toString(), label); } }
Example #10
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void processLibraryLocation(LibraryLocation[] libLocations, String label) { for (int l= 0; l < libLocations.length; l++) { LibraryLocation location= libLocations[l]; fLib2Name.put(location.getSystemLibraryPath(), label); } }
Example #11
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void processLibraryLocation(LibraryLocation[] libLocations, String label) { for (int l= 0; l < libLocations.length; l++) { LibraryLocation location= libLocations[l]; fLib2Name.put(location.getSystemLibraryPath().toString(), label); } }
Example #12
Source File: AbstractSARLLaunchConfigurationDelegate.java From sarl with Apache License 2.0 | 4 votes |
@SuppressWarnings("checkstyle:npathcomplexity") private void getBootpathExtForJRE(ILaunchConfiguration configuration, IRuntimeClasspathEntry[] entries, IRuntimeClasspathEntry jreEntry, int idx, String[] entriesPrep, IRuntimeClasspathEntry[] bootEntriesPrep, String[][] bootpathInfo) throws CoreException { int index = idx; final List<IRuntimeClasspathEntry> bootEntriesAppend = new ArrayList<>(); for (; index < entries.length; index++) { final IRuntimeClasspathEntry entry = entries[index]; if (entry.getClasspathProperty() == IRuntimeClasspathEntry.BOOTSTRAP_CLASSES) { bootEntriesAppend.add(entry); } } bootpathInfo[0] = entriesPrep; final IRuntimeClasspathEntry[] bootEntriesApp = JavaRuntime .resolveRuntimeClasspath( bootEntriesAppend .toArray(new IRuntimeClasspathEntry[bootEntriesAppend .size()]), configuration); if (bootEntriesApp.length > 0) { bootpathInfo[2] = new String[bootEntriesApp.length]; for (int i = 0; i < bootEntriesApp.length; i++) { bootpathInfo[2][i] = bootEntriesApp[i].getLocation(); } } final IVMInstall install = getVMInstall(configuration); final LibraryLocation[] libraryLocations = install.getLibraryLocations(); if (libraryLocations != null) { // determine if explicit bootpath should be used if (!JRERuntimeClasspathEntryResolver.isSameArchives(libraryLocations, install.getVMInstallType().getDefaultLibraryLocations(install.getInstallLocation()))) { // resolve bootpath entries in JRE entry final IRuntimeClasspathEntry[] bootEntries; if (jreEntry.getType() == IRuntimeClasspathEntry.CONTAINER) { final IRuntimeClasspathEntry bootEntry = JavaRuntime.newRuntimeContainerClasspathEntry( jreEntry.getPath(), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES, getJavaProject(configuration)); bootEntries = JavaRuntime.resolveRuntimeClasspathEntry(bootEntry, configuration); } else { bootEntries = JavaRuntime.resolveRuntimeClasspathEntry(jreEntry, configuration); } // non-default JRE libraries - use explicit bootpath only final String[] bootpath = new String[bootEntriesPrep.length + bootEntries.length + bootEntriesApp.length]; if (bootEntriesPrep.length > 0) { System.arraycopy(bootpathInfo[0], 0, bootpath, 0, bootEntriesPrep.length); } int dest = bootEntriesPrep.length; for (int i = 0; i < bootEntries.length; i++) { bootpath[dest] = bootEntries[i].getLocation(); dest++; } if (bootEntriesApp.length > 0) { System.arraycopy(bootpathInfo[2], 0, bootpath, dest, bootEntriesApp.length); } bootpathInfo[0] = null; bootpathInfo[1] = bootpath; bootpathInfo[2] = null; } } }
Example #13
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 3 votes |
@Override public void createJavaProject(String projectName) throws RemoteException { log.trace("creating java project: " + projectName); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { project.create(null); project.open(null); IProjectDescription description = project.getDescription(); description.setNatureIds(new String[] {JavaCore.NATURE_ID}); project.setDescription(description, null); IJavaProject javaProject = JavaCore.create(project); Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>(); entries.add(JavaCore.newSourceEntry(javaProject.getPath().append("src"), new IPath[0])); IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall); for (LibraryLocation element : locations) { entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null)); } javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); } catch (CoreException e) { log.error("unable to create java project '" + projectName + "' :" + e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }