gpt4 book ai didi

java - Eclipse 启动配置失败 : What does ResourcesPlugin. getWorkspace().getRoot().getFile() 评估为

转载 作者:行者123 更新时间:2023-12-01 14:25:54 26 4
gpt4 key购买 nike

我正在尝试从 Eclipse 启动配置(“调试”>“调试配置”)加载文件。但是我不认为我的文件位于 Eclipse 运行时识别的正确位置。这是代码。

1 . Step 1 : Fetch the name of the program from the launch configuration 

2 . Step 2 : Check if the file exits .

我每次都会中止。所以看来我的文件位置不正确。但我确信是的。

编辑

我使用以下 API String path ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program)).getRawLocation().toString(); 来确定该位置正在被搜查。然而,令人惊讶的是,以下 API 无法看到该成员存在于路径中

API 失败

String text = fProgramText.getText();
if (text.length() > 0) {
IPath path = new Path(text);
if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) == null) {
setErrorMessage("Specified program does not exist");
return false;
}
} else {
setMessage("Specify a program");
}

最佳答案

发送

ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program))

getRawLocation() 方法:

String path = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program)).getRawLocation().toString();

这将为您提供文件的系统文件名(完全限定)...或者至少 Eclipse 认为您的文件应该在的位置。

如果该文件位于 Eclipse 正在查找的位置,但 Eclipse 没有看到它,您可能必须发送refreshLocal() 方法来将工作区与文件系统同步。当您在 Eclipse 外部编辑工作区字段时通常会出现这种情况。

关于java - Eclipse 启动配置失败 : What does ResourcesPlugin. getWorkspace().getRoot().getFile() 评估为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17181882/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com