在 32 位和 64 位 Linux 系统上开发 Java Eclipse 项目

发布于 2024-10-06 07:05:20 字数 921 浏览 0 评论 0原文

我有一系列相关项目,已置于 Git 控制之下(所有这些项目都在同一个工作区中,这是 Git 存储库的顶层),并从我的桌面(32 位)克隆到我的笔记本电脑(64 位)这样我就可以在任何地方处理它们。工作区 .metadata 文件夹被排除,但项目文件夹中的所有内容都会被跟踪。

当我在笔记本电脑上打开克隆的工作区时,出现了一个错误:

Project 'project' is missing required library:
'/usr/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_3.5.2.v3557f.jar'

显然,64 位 eclipse 没有 32 位库,但我很好奇应该如何解决这个问题。

该库已作为 Window Builder SWT/JFace 项目模板的一部分添加。 eclipse 插件文件夹中有一个 org.eclipse.swt_3.5.2.v3557f.jar ,但是更改类路径来查找它不起作用(奇怪的是,没有找到 SWT)。查看 SWT/JFace 项目的 .classpath 文件的其余部分,这个特定的库是唯一如此特定于平台的库。

我将库的两个版本都放在 .classpath 中,这允许代码构建/运行,尽管我必须忽略构建路径错误,并且当我拉取时,此错误将传播回我的桌面笔记本电脑又变回来了。

我可以将笔记本电脑上的 64 位 jar 符号链接到 32 位名称,以便类路径可以找到该库吗?还有其他更好的解决方案吗?

更新: 看起来此类项目必须依赖于具体的 SWT 片段,因此在出现更好的解决方案之前,我将在两台机器上对相关片段进行符号链接,以将编译器引导到正确的片段。在其他机器(尤其是 Windows)上构建/运行项目将会非常有趣!但当我到达那里时我会建造那座桥。

I have a series of related projects that I've placed under Git control (all these projects are in the same workspace, which is the top-level of the Git repository) and cloned from my desktop (32bit) to my laptop (64bit) so I can work on them wherever. The workspace .metadata folder is excluded, but everything in the project folders is tracked.

When I opened the cloned workspace on the laptop, I was greeted by an error:

Project 'project' is missing required library:
'/usr/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_3.5.2.v3557f.jar'

Obviously, the 64bit eclipse doesn't have the 32bit libraries, but I'm curious as to how this should be resolved.

That library was added as part of the Window Builder SWT/JFace Project template. There is a org.eclipse.swt_3.5.2.v3557f.jar in the eclipse plugins folder, but changing the classpath to look for that doesn't work (doesn't find SWT, oddly). Looking through the rest of the .classpath file for the SWT/JFace projects, this particular library is the only one that is so platform specific.

I put both versions of the library in the .classpath and this allows the code to build/run, though I have to ignore the build path error, and this error will propagate back to my desktop when I pull the laptop changes back.

Can I just symlink the 64bit jar on the laptop to the 32bit name so the classpath can find the library? Is there another, better solution?

UPDATE:
It looks like this type of project has to depend on the concrete SWT fragment, so until there's a better solution I'm going to symlink the fragments in question on both machines to direct the compiler to the correct fragment. Building/running the projects on other machines (and especially Windows) will be !!Fun!! but I'll build that bridge when I get there.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

会傲 2024-10-13 07:05:20

您在源代码管理中到底保留了什么?

最佳实践是仅在源存储库中保留手写的源文件。不是二进制文件、生成的文件或 IDE 设置。

我认为您的 64 位 Eclipse 的 IDE 设置存在问题,无法与 32 位 Eclipse 一起使用。

只需删除工作区中的 .metadata 目录,然后重新导入此 Eclipse 中的所有项目即可。

What exactly are you keeping in your source control?

The best practice is to keep only hand-written source files on source repository. Not binaries, or generated files, or IDE settings.

I think you have the problem with the IDE settings for your 64bit Eclipse not working with 32bit one.

Just delete .metadata directory in your workspace, and reimport all projects in this Eclipse.

狠疯拽 2024-10-13 07:05:20

不要对整个工作区进行此操作。只需对各个项目进行操作即可。在这里运作良好。

Don't do it with the whole workspace. Just do it with the individual projects. Works well here.

安静 2024-10-13 07:05:20

您正在开发哪种类型的项目? java项目还是插件项目?

如果您正在开发插件项目,您的项目不应直接依赖于具体的 swt 片段(例如 swt.gtk、swt.win32)。 swt的实际实现是在不同平台上的不同片段,这应该取决于宿主插件“org.eclipse.swt”。

如果您正在开发一个java项目,需要swt作为第三方需求。您可以为 32 位和 64 位 eclipse 安装 eclipse delta 软件包。

Which type of the project you are developing? The java project or plug-in project?

If you're developing plug-in project, your project should not directly depend on the concrete swt fragment(such as swt.gtk, swt.win32). It should depend on the host plug-in 'org.eclipse.swt' that the actual implementation of swt is the different fragments in different platforms.

If you're developing a java project that requires the swt as the third-party requirement. You can install eclipse delta package for both your 32bit and 64bit eclipse.

苦笑流年记忆 2024-10-13 07:05:20

为了避免平台问题,您还可以考虑 Maven。使用 Maven 2 或 3,通过配置文件的可选组合,平台问题可以很容易地得到解决。
使用一些适用于 Eclipse 的 Maven 插件,可以将 Maven 项目直接导入到 Eclipse 中。

To avoid platform issues, you could also consider Maven. Using Maven 2 or 3, with optional combination of profiles platform issues can be resolved quite easily.
Using a few Maven plugins for Eclipse, Maven projects can be imported into Eclipse directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文