为什么 IResource.getRawLocation() 为 IProject 返回 null

2023-08-22Java开发问题
5

本文介绍了为什么 IResource.getRawLocation() 为 IProject 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我需要一个项目文件夹的绝对位置,所以我尝试了

I need the absolute location of a project folder, so I tried

project.getRawLocation()

但这会返回 null (至少在我使用 Import ... Existing projects into workspace 手动导入项目的情况下,我已经检查了 将项目复制到工作区复选框).

but this returns null (at least in my case in which I have imported the project manually using Import ... Existing projects into workspace and I have checked the Copy projects into workspace checkbox).

事情是这样的

project.getParent().getRawLocation() 

返回正确的 /work/Projekte/runtime-MyProduct.product

project.members()[0].getRawLocation()

返回 /work/Projekte/runtime-MyProduct.product/Test/.cproject 这也是正确的.

returns /work/Projekte/runtime-MyProduct.product/Test/.cproject which is correct as well.

因此,我希望如此

project.getRawLocation() 

会返回 /work/Projekte/runtime-MyProduct.product/Test,但它会返回 null.

would return /work/Projekte/runtime-MyProduct.product/Test, but it returns null.

谁能解释和/或告诉我哪里错了?

Can anyone explain and/or show me where I'm wrong?

推荐答案

getRawLocation()

如果此资源是现有项目,则返回的路径将为等于项目描述中的位置路径.

If this resource is an existing project, the returned path will be equal to the location path in the project description.

以及项目描述的 JavaDoc IProjectDescription.getLocation() 说:

and the JavaDoc for the project description IProjectDescription.getLocation() says:

如果应该使用默认位置,则返回null

null is returned if the default location should be used

getLocation() 调用会返回一个路径.

The getLocation() call will return a path.

这篇关于为什么 IResource.getRawLocation() 为 IProject 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

Eclipse 在尝试启动 Android 应用程序时卡住了
Eclipse gets stuck when trying to launch Android app(Eclipse 在尝试启动 Android 应用程序时卡住了)...
2024-08-25 Java开发问题
14

Java 代表?
Java Delegates?(Java 代表?)...
2024-08-25 Java开发问题
15

Eclipse:无法初始化监视器线程:无法建立环回连接
Eclipse: Failed to initialize Monitor Thread: Unable to establish loopback connection(Eclipse:无法初始化监视器线程:无法建立环回连接)...
2024-08-25 Java开发问题
4

Eclipse-找不到JDK
Eclipse- JDK not found(Eclipse-找不到JDK)...
2024-08-25 Java开发问题
6