4

On Windows package org.eclipse.swt.win32.win32.x86_64 is used, while for Linux build it's org.eclipse.swt.gtk.linux.x86_64.

  1. If nothing is specified in module-info.java, error message is java: package org.eclipse.swt does not exist

  2. If in module-info.java both are specified:

    requires org.eclipse.swt.gtk.linux.x86_64;
    requires org.eclipse.swt.win32.win32.x86_64;
    

    error message: module ... reads package org.eclipse.swt from both org.eclipse.swt.gtk.linux.x86_64 and org.eclipse.swt.win32.win32.x86_64

  3. If only one requires is specified, then project works only on one platform.

What would be correct setup for module-info.java, so that project would run on both platforms?

iljau
  • 2,151
  • 3
  • 22
  • 45
  • It isn't really possible to build a single SWT app that will run on all platforms, you need a separate build for each platform. – greg-449 Nov 05 '21 at 18:25
  • I'm using different build profiles in maven, so based on platform (unix/windows) corresponding SWT dependency is added. This works until trying to add `module-info.java`. – iljau Nov 05 '21 at 18:35
  • There was a related question [here](https://stackoverflow.com/q/65539331/2670892), the answer just uses `requires swt;` Not sure it really addresses cross platform. – greg-449 Nov 06 '21 at 08:14
  • Is this just an SWT app or is it an Eclipse based RCP? [tag:tycho] is used for RCP builds and understands cross platform. – greg-449 Nov 06 '21 at 08:20
  • It's standalone SWT app. Using just `requires swt;` gives `module not found: swt`, so some additional setup may be required for this case. But it's not clear to me what this additional setup may be. – iljau Nov 06 '21 at 08:30
  • The answer to the related question seems to go through the setup in detail, have you looked at that.? – greg-449 Nov 06 '21 at 09:01
  • It looks like that `requires swt` in linked answer comes from `swt.jar`, that was in downloaded zip file. As I'm using SWT builds from maven, my module names are as specified in question. My question would be how to specify `requires` in `module-info.java`, that would work for both Linux and Windows build. – iljau Nov 06 '21 at 09:21

1 Answers1

0

It's a bug 559162 in SWT. Their Automatic-Module-Name in the SWT jar files manifest is impractical.

I suggest to stick to module-less builds (without module-info.java) until this gets fixed.

Alexey Veleshko
  • 792
  • 1
  • 18