本文整理汇总了Java中org.eclipse.jdt.launching.JavaRuntime.computeDefaultRuntimeClassPath方法的典型用法代码示例。如果您正苦于以下问题:Java JavaRuntime.computeDefaultRuntimeClassPath方法的具体用法?Java JavaRuntime.computeDefaultRuntimeClassPath怎么用?Java JavaRuntime.computeDefaultRuntimeClassPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.launching.JavaRuntime
的用法示例。
在下文中一共展示了JavaRuntime.computeDefaultRuntimeClassPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProjectClassPathList
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* @return
*/
public static List<String> getProjectClassPathList() {
final String projects = getProjects();
final List<String> projectList = toArrayList(projects, PATH_SEPARATOR);
final List<String> projectClassPathList = new ArrayList<>();
final Iterator<String> iterator = projectList.iterator();
while (iterator.hasNext()) {
final String projectName = iterator.next();
final IProject iproject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
final IJavaProject jproject = JavaCore.create(iproject);
try {
if ((jproject != null) && jproject.exists() && jproject.isOpen()) {
final String[] projectcp = JavaRuntime.computeDefaultRuntimeClassPath(jproject);
for (final String element : projectcp) {
projectClassPathList.add(element);
}
}
} catch (final CoreException localCoreException) {
}
}
return projectClassPathList;
}
示例2: buildOfflineShellFile
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public static File buildOfflineShellFile(IJavaProject jproject, IFile graphModel, String pathGenerator,
String startElement) throws CoreException, IOException {
IRuntimeClasspathEntry e = JavaRuntime.computeJREEntry(jproject);
IVMInstall intall = JavaRuntime.getVMInstall(e.getPath());
StringBuilder sb = new StringBuilder();
File javaLocation = intall.getInstallLocation();
sb.append(javaLocation.getAbsolutePath()).append(File.separator).append("bin").append(File.separator)
.append("java").append(" -cp ").append("\"");
String cpSeparator = "";
String[] classpath = JavaRuntime.computeDefaultRuntimeClassPath(jproject);
for (String cpElement : classpath) {
sb.append(cpSeparator).append(cpElement);
cpSeparator = System.getProperty("path.separator");
}
sb.append("\"").append(" org.graphwalker.cli.CLI ").append(" offline ").append(" -m ")
.append(ResourceManager.toFile(graphModel.getFullPath()).getAbsolutePath()).append(" \"")
.append(pathGenerator).append("\" ").append(" -e ").append(startElement).append(" --verbose ");
String extension = isWindows() ? "bat" : "sh";
Path path = Files.createTempFile("offlineShellRunner", "." + extension);
Files.write(path, sb.toString().getBytes(StandardCharsets.UTF_8));
File file = path.toFile();
ResourceManager.logInfo(jproject.getProject().getName(), "Shell file : " + file.getAbsolutePath());
return file;
}
示例3: computeClassPath
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* Compute runtime classpath of a java project.
*
* @param javaProject
* java project
* @return class path
* @throws CoreException
* CoreException
*/
private static String[][] computeClassPath(IJavaProject javaProject) throws CoreException {
if (javaProject == null) {
throw new IllegalArgumentException("javaProject is null");
}
String[][] result = new String[2][];
if (JavaRuntime.isModularProject(javaProject)) {
result[0] = JavaRuntime.computeDefaultRuntimeClassPath(javaProject);
result[1] = new String[0];
} else {
result[0] = new String[0];
result[1] = JavaRuntime.computeDefaultRuntimeClassPath(javaProject);
}
return result;
}
示例4: getAbsolutePath
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private String getAbsolutePath(IJavaProject jProject, String packageName) {
try {
return JavaRuntime.computeDefaultRuntimeClassPath(jProject)[0]
+ (Path.SEPARATOR + packageName.replace(".", "/") + Path.SEPARATOR);
} catch (CoreException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例5: getProjectClassLoader
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* get the <code>ClassLoader</code> of java project specified.
*
* @param project <code>IJavaProject</code>
* @return <code>ClassLoader</code> of java project
* @throws CoreException
* @throws MalformedURLException
*/
public static ClassLoader getProjectClassLoader(IJavaProject project)
throws CoreException,MalformedURLException {
//compute the project classpaths
//REVIEW: Are the classpaths returned by computeDefaultRuntimeClassPath enough to load class?
String[] classPaths = JavaRuntime.computeDefaultRuntimeClassPath(project);
URL[] urls = new URL[classPaths.length];
for (int i = 0; i < classPaths.length; i++) {
urls[i] = new URL(PROTOCAL_PREFIX + computeForURLClassLoader(classPaths[i]));
}
return new URLClassLoader(urls);
}
示例6: getCurrentProjectClassLoader
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* get the <code>ClassLoader</code> of current java project.
*
* @return <code>ClassLoader</code> of java project
* @throws CoreException
* @throws MalformedURLException
*/
public static ClassLoader getCurrentProjectClassLoader()
throws CoreException,MalformedURLException {
//compute the project classpaths
//REVIEW: Are the classpaths returned by computeDefaultRuntimeClassPath enough to load class?
String[] classPaths = JavaRuntime.computeDefaultRuntimeClassPath(ProjectHelper.getCurrentJavaProject());
URL[] urls = new URL[classPaths.length];
for (int i = 0; i < classPaths.length; i++) {
urls[i] = new URL(PROTOCAL_PREFIX + computeForURLClassLoader(classPaths[i]));
}
return new URLClassLoader(urls);
}
示例7: getCurrentClassPath
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public static String getCurrentClassPath(){
try {
return JavaRuntime.computeDefaultRuntimeClassPath(getCurrentJavaProject())[0];
} catch (CoreException e) {
e.printStackTrace();
}
return ".";
}
示例8: getProjectClassLoader
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* get the <code>ClassLoader</code> of java project specified.
*
* @param project
* <code>IJavaProject</code>
* @return <code>ClassLoader</code> of java project
* @throws CoreException
* @throws MalformedURLException
*/
public static ClassLoader getProjectClassLoader(IJavaProject project)
throws CoreException, MalformedURLException {
String[] classPaths = JavaRuntime.computeDefaultRuntimeClassPath(project);
URL[] urls = new URL[classPaths.length];
for (int i = 0; i < classPaths.length; i++) {
urls[i] = new URL(PROTOCAL_PREFIX
+ computeForURLClassLoader(classPaths[i]));
}
return new URLClassLoader(urls);
}
示例9: dependenciesForProject
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* Expand out the list of dependencies for a given IJavaProject.
*/
private List<IRuntimeClasspathEntry> dependenciesForProject(IJavaProject project)
throws CoreException {
ArrayList<IRuntimeClasspathEntry> out = new ArrayList<IRuntimeClasspathEntry>();
String[] deps = JavaRuntime.computeDefaultRuntimeClassPath(project);
for (String dep : deps) {
IRuntimeClasspathEntry cpEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(dep));
out.add(cpEntry);
}
return out;
}
示例10: createClassLoader
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* Returns a {@link ClassLoader} that is backed by the project's runtime classpath.
*
* TODO: This returns a classloader which contains ALL of the jars of the project. Lookups on
* this thing are going to be SLOW. Can we optimize this? We could create a classloader that
* just contains the jars that GWT requires. Maybe caching is the right solution here.
*
* TODO: Why can't we just delegate to {@link #getClasspathEntries()} when generating the
* classloader URLs? Why do we have to add every URL that is part of the project? That would
* certainly speed up lookups on this classloader. Maybe we cannot do this because project-bound
* sdks handle the case of source-based runtimes, and in that case, we need all of the
* dependencies as part of the classloader.
*/
@Override
public URLClassLoader createClassLoader() throws SdkException, MalformedURLException {
try {
String[] defaultRuntimeClasspath = JavaRuntime.computeDefaultRuntimeClassPath(javaProject);
URL[] urls = new URL[defaultRuntimeClasspath.length];
for (int i = 0; i < defaultRuntimeClasspath.length; ++i) {
File file = new File(defaultRuntimeClasspath[i]);
urls[i] = file.toURI().toURL();
}
return new URLClassLoader(urls);
} catch (CoreException e) {
throw new SdkException(e);
}
}
示例11: getProjectClasspathUrls
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private URL[] getProjectClasspathUrls() throws CoreException, MalformedURLException {
IProject project = processFolder.getProject();
IJavaProject javaProject = JavaCore.create(project);
String[] pathArray = JavaRuntime
.computeDefaultRuntimeClassPath(javaProject);
URL[] urls = new URL[pathArray.length];
for (int i = 0; i < pathArray.length; i++) {
urls[i] = new File(pathArray[i]).toURI().toURL();
}
return urls;
}
示例12: getClassLoaderForProject
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* Returns a ClassLoader for the Project attached to the parent.
* @param project
* @param parent
* @return
*/
public static URLClassLoader getClassLoaderForProject(IProject project, ClassLoader parent){
String[] classPathEntries;
try{
IJavaProject javaproject = JavaCore.create(project);
classPathEntries = JavaRuntime.computeDefaultRuntimeClassPath(javaproject);
}catch(CoreException e){
classPathEntries = new String[]{};
}
URL[] urls = getClassPathEntyUrls(classPathEntries);
URLClassLoader classLoader = new URLClassLoader(urls, parent);
return classLoader;
}
示例13: getClassPath
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private IPath[] getClassPath(IJavaProject[] javaProjects) {
HashSet<IPath> res= new HashSet<IPath>();
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
for (int j= 0; j < javaProjects.length; j++) {
IJavaProject curr= javaProjects[j];
try {
IPath outputLocation= null;
// Not really clear yet what to do here for EFS. See bug
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=113233.
// However if the output location is not local it is currently
// not part of JavaRuntime.computeDefaultRuntimeClassPath either
// so it will be simply not added to the result which would be
// correct.
IResource outputPathFolder= root.findMember(curr.getOutputLocation());
if (outputPathFolder != null)
outputLocation= outputPathFolder.getLocation();
String[] classPath= JavaRuntime.computeDefaultRuntimeClassPath(curr);
for (int i= 0; i < classPath.length; i++) {
IPath path= Path.fromOSString(classPath[i]);
if (!path.equals(outputLocation)) {
res.add(path);
}
}
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
return res.toArray(new IPath[res.size()]);
}
示例14: Platform
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
Platform(IJavaProject platformJavaProject) throws CoreException {
this.platformJavaProject = platformJavaProject;
this.classPath = JavaRuntime.computeDefaultRuntimeClassPath(platformJavaProject);
}
示例15: prepareExpressionEvaluator
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
@Override
public void prepareExpressionEvaluator(JRDesignDataset dataset, JasperDesign jasperDesign,
JasperReportsConfiguration jConfig) throws Exception {
super.prepareExpressionEvaluator(dataset, jasperDesign, jConfig);
interpreter = new Interpreter();
// I need to add to the classpath the document directory...
// Look for the JrxmlVisualView parent of the scene...
if (classLoader != null)
interpreter.setClassLoader(classLoader);
// Staring patch from rp4
interpreter.eval("String tmp;");
try {
if (javaProject != null) {
String[] cpaths = JavaRuntime.computeDefaultRuntimeClassPath(javaProject);
for (String p : cpaths) {
if (Misc.isNullOrEmpty(p))
continue;
interpreter.set("tmp", p);
interpreter.eval("addClassPath(tmp);");
}
}
} catch (CoreException e) {
e.printStackTrace();
}
// Add report import directives to the bsh interpreter
interpreter.eval("import net.sf.jasperreports.engine.*;");
interpreter.eval("import net.sf.jasperreports.engine.fill.*;");
interpreter.eval("import java.util.*;");
interpreter.eval("import java.math.*;");
interpreter.eval("import java.text.*;");
interpreter.eval("import java.io.*;");
interpreter.eval("import java.net.*;");
interpreter.eval("import java.util.*;");
interpreter.eval("import net.sf.jasperreports.engine.data.*;");
if (jasperDesign != null) {
String[] imports = jasperDesign.getImports();
for (int i = 0; imports != null && i < imports.length; ++i) {
String importString = imports[i];
if (importString.startsWith("static "))
interpreter.eval("static import " + imports[i].substring("static ".length()) + ";");
else
interpreter.eval("import " + imports[i] + ";");
}
}
}