-1

I wrote modular JavaFx Maven project in Eclipse IDE.

Now I am trying to convert it to runnable jarfile, but receive the following error after clicking Next.

How can I fix this?

Details button provides the same text:

An error has occurred. See error log for more details.
Cannot invoke "org.eclipse.swt.widgets.Combo.getText()" because "this.fDestinationNamesCombo" 
is null
vvslava
  • 1
  • 2
  • I’m guessing that the error is actually (and surprisingly) generated by Eclipse and you aren’t actually using that class or any SWT classes in your app. Can you confirm that? – jewelsea Jan 21 '22 at 02:25
  • 2
    Duplicate: ["this.fDestinationNamesCombo" is null.](https://stackoverflow.com/questions/70486758/i-want-to-convert-my-console-program-to-a-runnable-jar-file). There are no answers for the duplicate, so this question cannot currently be closed as a duplicate. – jewelsea Jan 21 '22 at 02:48
  • 1
    It would appear to be a bug in Eclipse, you could check their bug tracker and file a bug report about it if you want. – jewelsea Jan 21 '22 at 02:49
  • 1
    Don’t try to create a jar using the Eclipse IDE create jar feature. You are using maven, [use maven to create the jar](https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing). Be aware that such a configuration is unsupported and not recommended, as mentioned in the link. – jewelsea Jan 21 '22 at 02:51
  • @jewelsea If _modular_ means here using the [Java Platform Module System (JPMS)](https://en.wikipedia.org/wiki/Java_Platform_Module_System) (by having a `module-info.java` file), it cannot be exported as fat/uber JAR since different modules cannot be packed into a single JAR file. That's a restriction of Java, not a bug of Eclipse (of course it would be nice if Eclipse would give a better error message; so please feel free to provide a patch for this). – howlger Jan 21 '22 at 10:38
  • @jewelsea no, I don't use any SWT classes in my app. Thank you, I'll try to create jar using maven. Should I switch to IntelliJIDEA in order to avoid those types of bugs in the future? – vvslava Jan 21 '22 at 15:14
  • @howgler yes, my project has 'module-info.java' file. So, exporting project directly through maven is the only way to create jar-file? – vvslava Jan 21 '22 at 15:18
  • @vvslava No, it's not possible. You can create a JAR that contains only your code (via Eclipse, Maven, etc.), but not a JAR that contains JavaFX and other dependencies (as so-called runnable, fat or uber JAR). A JAR file is a ZIP archive that contains the .class file and your `module-info.java` of the default package will be compiled to `module-info.class` in the root of the JAR. But this would clash with the other `module-info.class` files from the other dependencies. Modules have to be separate JARs. – howlger Jan 21 '22 at 18:26
  • @howlger thanks a lot for your detailed answer! – vvslava Jan 21 '22 at 23:43
  • @howlger To clarify my comments: yes you are correct, multiple modules cannot be packed into a single Jar, each needs to be packed into a separate jar and run from the module path. JavaFX apps can (currently) run from the classpath, but you lose modularity and it is not supported or recommended (explained in the [linked answer](https://stackoverflow.com/a/52654791/1155209)). I added a [packaging section to the javafx tag](https://stackoverflow.com/tags/javafx/info) for additional resources on alternatives. – jewelsea Jan 22 '22 at 00:19
  • "Should I switch to IntelliJIDEA in order to avoid those types of bugs in the future?" -> No, not for this reason. This is not a core IDE function. The IDEs are complex and each has issues, errors and is sub-optimal in some way. Choose your IDE on other criteria. What you should do, IMO, is to use a dedicated build tool (e.g. Maven or Gradle) with appropriate plugins or write scripts for the packaging rather than relying on packaging functionality built into the IDE. There is info on that in the [packaging section of the javafx tag](https://stackoverflow.com/tags/javafx/info). – jewelsea Jan 22 '22 at 00:27
  • @howlger I haven't looked at the Eclipse codebase to see why it generates the message `"this.fDestinationNamesCombo" is null`. It may be due to it being a modular app, I don't know though. I don't use Ecplise and don't know SWT, so, unfortunately, I can't patch it easily. If I can find the time, I'll consider further investigation or filing a bug report on this for the Eclipse project if I can't find an existing issue. – jewelsea Jan 22 '22 at 00:35
  • @jewelsea thanks a lot for your detailed answers! – vvslava Jan 26 '22 at 19:24

2 Answers2

0

I had the same problem and noticed @jewelsea's suggestion in the comments regarding Maven and it led me to a solution in my case. I'm working with libgdx and used the libgdx Project Setup tool to create the project and then applied their suggestions for converting to the Lwjgl3 library. Exporting the jar in Eclipse didn't work because I got the same fDestinationNamesCombo error. Instead, I used this batch command (which the gdxlib setup tool put in the project directory) in a Windows command prompt: "gradlew desktop:dist". This created a working jar in the desktop\build\libs directory.

Pedro-McM
  • 1
  • 1
0

Try this:

Project -> Properties -> Run/Debug Settings:

select "Launching New_configuration" and others like this.

Delete

it works for me.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Mohammed Fadhl Oct 19 '22 at 19:07