Erik Youngren
Erik Youngren

Reputation: 811

Developing a Java Eclipse project on both 32bit and 64bit Linux systems

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.

Upvotes: 4

Views: 1732

Answers (4)

Gerbrand
Gerbrand

Reputation: 1633

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.

Upvotes: 0

Kane
Kane

Reputation: 8172

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.

Upvotes: 1

Goran Jovic
Goran Jovic

Reputation: 9508

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.

Upvotes: 1

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

Upvotes: 1

Related Questions