- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试通过 ResourcesPlugin 获取工作区时出现此错误:
java.lang.IllegalStateException: Workspace is closed.
at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:339)
生成此代码的代码是:
IWorkspace ws = ResourcesPlugin.getWorkspace();
您能帮忙解决这个问题吗?
最佳答案
您的 Manifest.MF
中的 Require-bundle
部分是否包含 org.eclipse.core.resources
?
您是否将测试作为插件启动? (不是作为“Java 应用程序”)
另请参阅this thread .
如“Resources and the file system”帮助页面中所述,
<小时/>You can access the workspace from the resources plug-in class (defined in
org.eclipse.core.resources
).When the resources plug-in is not running, the workspace exists solely in the file system and is viewed or manipulated by the user via standard file-based tools. Let's look at what a workspace looks like on disk as we explain the resources plug-in API.
来自this book :
The workspace directory, regardless of the name defined with the
-data
invocation option, has two roles:
- it acts as the parent for the
.metadata
directory- and as the default location for projects
the workspace can contains projects only when:
- the
org.eclipse.core.resources
plugin is included in the configuration and- and appropriately started from the workbench
this is automatic from an IDE configuration based on the
org.eclipse.ui.ide.workbench
application.
另请参阅this thread并记住:
the workspace is a different workspace from the runtime-workspace that's used for testing plugins. When you do Run on an Eclipse PDE environment, it creates a new workspace which is completely empty.
测试workspace root can be specified through the "-data"启动选项。
If you want to access a file, your best bet is to include it in the plugin itself, and then use
getClass().getResourceAsStream("/myfile.txt")
to get anInputStream
that you can read the contents for.
关于eclipse - 尝试通过ResourcesPlugin获取工作区时出现"Workspace is closed"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/962364/
启动插件时,我有一些代码调用 getWorkspace() ResourcesPlugin 类的方法。这将返回当前工作区。但是,是否可以改为指定工作区? 最佳答案 一次只能在 Eclipse 中加载一
我正在尝试从 Eclipse 启动配置(“调试”>“调试配置”)加载文件。但是我不认为我的文件位于 Eclipse 运行时识别的正确位置。这是代码。 1 . Step 1 : Fetch the na
我目前正在尝试使用 eclipses 工作区访问我的 eclipse 项目和项目抽象,但我很快就失败了。 请看下面的代码: public static void main(String[] args)
我是一名优秀的程序员,十分优秀!