You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Eclipse插件所需额外动态外部内容的合适下载位置咨询

Great question—storing external non-OSGi content directly in the Eclipse install directory works for basic cases, but it’s far from ideal (especially if Eclipse is installed in a system-protected path like C:\Program Files on Windows, where regular users might lack write permissions, or if you ever update Eclipse and risk losing those downloaded files).

Here are the Eclipse-standard, more appropriate locations you should use instead, organized by use case:

1. Eclipse Instance Data Directory

This is the per-workspace instance directory, which defaults to something like ${user.home}/.eclipse/org.eclipse.platform_<your-eclipse-version> (the exact path varies slightly by Eclipse release). If users launch Eclipse with the -data flag pointing to a custom workspace folder, this location will be tied to that specified path.

  • Best for content that’s specific to a particular workspace/instance (e.g., project-dependent external tools or resources).
  • You can dynamically retrieve this path in code using Platform.getInstanceLocation(), so you don’t have to hardcode anything.

2. Eclipse User Home Directory

Located at ${user.home}/.eclipse (consistent across Windows, macOS, and Linux), this is a user-level directory shared across all of a user’s Eclipse instances.

  • Perfect for global content that should be accessible to any workspace the user launches (e.g., shared external libraries or tools used by multiple plugins).
  • Grab this path programmatically with Platform.getUserLocation().

3. Plugin-Specific State Location

Every Eclipse plugin gets its own dedicated state storage directory, nested under the instance data directory (usually at plugins/<your-plugin-id>).

  • Ideal for content that’s exclusively used by your plugin (e.g., plugin-specific external dependencies that don’t need to be shared with other plugins).
  • To get this path in code, use BundleContext.getDataFile("") (from your plugin’s activator) or Platform.getStateLocation(bundle) where bundle is your plugin’s Bundle object.

Why Avoid the Install Directory?

  • Permission Issues: System-wide Eclipse installs often restrict write access to the install directory for regular users, which will break your download logic.
  • Update Risk: When you update Eclipse (e.g., via the Eclipse Installer or Marketplace), the install directory may be overwritten, deleting your downloaded content.
  • Multi-User Conflicts: In a shared machine scenario, multiple users would overwrite each other’s files stored in the install directory.

Pick the location that aligns best with how your content is used—instance-specific, user-global, or plugin-exclusive—and you’ll be following Eclipse’s design conventions while avoiding common pitfalls.

内容的提问来源于stack exchange,提问作者Roberto Lo Giacco

火山引擎 最新活动