<i id='wTEa7'><tr id='wTEa7'><dt id='wTEa7'><q id='wTEa7'><span id='wTEa7'><b id='wTEa7'><form id='wTEa7'><ins id='wTEa7'></ins><ul id='wTEa7'></ul><sub id='wTEa7'></sub></form><legend id='wTEa7'></legend><bdo id='wTEa7'><pre id='wTEa7'><center id='wTEa7'></center></pre></bdo></b><th id='wTEa7'></th></span></q></dt></tr></i><div id='wTEa7'><tfoot id='wTEa7'></tfoot><dl id='wTEa7'><fieldset id='wTEa7'></fieldset></dl></div>
        <bdo id='wTEa7'></bdo><ul id='wTEa7'></ul>

      1. <tfoot id='wTEa7'></tfoot>
      2. <small id='wTEa7'></small><noframes id='wTEa7'>

        <legend id='wTEa7'><style id='wTEa7'><dir id='wTEa7'><q id='wTEa7'></q></dir></style></legend>

        无法将 eclipse 项目转换为 IJavaProject

        Cannot cast eclipse project to IJavaProject(无法将 eclipse 项目转换为 IJavaProject)
      3. <i id='gJmhW'><tr id='gJmhW'><dt id='gJmhW'><q id='gJmhW'><span id='gJmhW'><b id='gJmhW'><form id='gJmhW'><ins id='gJmhW'></ins><ul id='gJmhW'></ul><sub id='gJmhW'></sub></form><legend id='gJmhW'></legend><bdo id='gJmhW'><pre id='gJmhW'><center id='gJmhW'></center></pre></bdo></b><th id='gJmhW'></th></span></q></dt></tr></i><div id='gJmhW'><tfoot id='gJmhW'></tfoot><dl id='gJmhW'><fieldset id='gJmhW'></fieldset></dl></div>
          <bdo id='gJmhW'></bdo><ul id='gJmhW'></ul>

            <small id='gJmhW'></small><noframes id='gJmhW'>

            <tfoot id='gJmhW'></tfoot>
            <legend id='gJmhW'><style id='gJmhW'><dir id='gJmhW'><q id='gJmhW'></q></dir></style></legend>

                    <tbody id='gJmhW'></tbody>
                  本文介绍了无法将 eclipse 项目转换为 IJavaProject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下代码

                      IJavaProject targetProject = null;
                      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
                      for (IProject project : root.getProjects()) {
                          if (project.getName().equals(projName)) {
                              try {
                                  if (project.hasNature("org.eclipse.jdt.core.javanature")) {
                                      targetProject = (IJavaProject) project;
                                  }
                              } catch( ... ) {
                               // etc ...
                              }
                  

                  我想要做的实际上是返回一个与特定名称匹配的项目作为 IJavaProject.如您所见,我通过以下方式检查以确保相关项目具有 java 特性:

                  What I am trying to do is essentially return a project that matches a particular name as an IJavaProject. As you can see, I check to ensure that the project in question has a java nature by calling:

                  if (project.hasNature("org.eclipse.jdt.core.javanature")) {
                  

                  唉,我收到一个ClassCaseException"声明

                  Alas, I get a 'ClassCaseException' stating

                  java.lang.ClassCastException: 
                      org.eclipse.core.internal.resources.Project cannot be cast to org.eclipse.jdt.core.IJavaProject
                  

                  知道为什么吗?我会认为一旦 IProject 具有 Java 特性,它就可以转换为 IJavaProject.由于服务不可用,我目前无法访问 JDT Core API 这里.

                  Any idea why? I would have thought that once an IProject has a java nature, it can be cast to a IJavaProject. I can't get access to the JDT Core API at the moment as the service is unavailable here.

                  推荐答案

                  您答案中的代码不应该工作(错字?).以下是创建 IJavaProject 的方法:

                  The code in your answer shouldn't work (typo?). Here is how you can create an IJavaProject:

                  import org.eclipse.jdt.core.JavaCore
                  ...
                      if (project.hasNature(JavaCore.NATURE_ID)) {
                          targetProject = JavaCore.create(project);
                      }
                  

                  IProject 是 Eclipse 资源 API 中的一种类型,而 IJavaProject 是 Eclipse Java 模型中的一种类型.它们不是相同的抽象,但所有 IJavaProject 都有一个 IProject.

                  IProject is a type in the Eclipse Resources API and IJavaProject is a type in the Eclipse Java Model. They are not the same abstractions, but all IJavaProjects have an IProject.

                  这篇关于无法将 eclipse 项目转换为 IJavaProject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                  Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                  How can I specify the default JVM arguments for programs I run from eclipse?(如何为从 Eclipse 运行的程序指定默认 JVM 参数?)
                  Class JavaLaunchHelper is implemented in both ... libinstrument.dylib. One of the two will be used. Which one is undefined(JavaLaunchHelper 类在... libinstrument.dylib 中都实现了.将使用两者之一.哪个是未定义的) - IT屋-程序员软件开发技术分享
                  Running Eclipse on Windows 7 JRE and JDK not found(找不到在 Windows 7 JRE 和 JDK 上运行 Eclipse)
                  StringBuilder vs. .concat vs. quot;+quot; Operator relative performance different in eclipse than command line?(StringBuilder vs. .concat vs. “+eclipse中的操作员相对性能与命令行不同?)
                  <i id='EvcFE'><tr id='EvcFE'><dt id='EvcFE'><q id='EvcFE'><span id='EvcFE'><b id='EvcFE'><form id='EvcFE'><ins id='EvcFE'></ins><ul id='EvcFE'></ul><sub id='EvcFE'></sub></form><legend id='EvcFE'></legend><bdo id='EvcFE'><pre id='EvcFE'><center id='EvcFE'></center></pre></bdo></b><th id='EvcFE'></th></span></q></dt></tr></i><div id='EvcFE'><tfoot id='EvcFE'></tfoot><dl id='EvcFE'><fieldset id='EvcFE'></fieldset></dl></div>
                    <tbody id='EvcFE'></tbody>

                      <legend id='EvcFE'><style id='EvcFE'><dir id='EvcFE'><q id='EvcFE'></q></dir></style></legend>

                      <tfoot id='EvcFE'></tfoot>
                      • <bdo id='EvcFE'></bdo><ul id='EvcFE'></ul>

                            <small id='EvcFE'></small><noframes id='EvcFE'>