Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
626 views
in Technique[技术] by (71.8m points)

java - JavaFX 11 in Netbeans 10 (with Maven) has no Sources/Javadocs

I tried out the JavaFX tutorial for Netbeans with Maven and got it running without a problem. Maven found the artifacts, downloaded them, build the project and started it. But I get no code completion (Missing sources and Javadocs).

I tried to download the sources and javadocs for the maven dependencies in Netbeans, but only the sources/javadocs for the wrapper artifacts (e.g. the empty javafx-controls-11) are available. But no sources are found for the actual implementation (e.g. javafx-controls-11-linux).

Where do I find the sources/javadocs and how do I add them to Netbeans?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is an issue already filed about this at the OpenJFX docs.

While it hasn't been resolved yet, there is a possible workaround, based on:

NetBeans only adds javadoc/source jars for a jar with the exact same name and -javadoc/-source suffix

So here are the steps to solve it:

  • Install NetBeans 10 and JDK 11.0.2.

  • Clone the HelloFX sample for NetBeans and Maven, from the OpenJFX samples.

  • Update the JavaFX dependencies to 11.0.2.

    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>11.0.2</version>
    </dependency>
    
  • Run it:

    mvn clean compile exec:java
    
  • Check that the JavaFX dependencies have been downloaded to your local m2 repository. Under <user home>/.m2/repository/org/openjfx/javafx-base/11.0.2 for instance you will find javafx-base-11.0.2.jar and javafx-base-mac-11.0.2.jar (or win, or linux based on your platform).

  • Back on NetBeans, right click in the Dependencies folder and select Download Sources (see the task progress in the bottom right taskbar), and then Download Javadoc(see the task progress).

image

  • Go to your m2 repository and verify that there are now -source and -javadoc jar files.

image

However, this won't solve the issue yet, there is an extra step:

  • In your m2 repository, manually rename the -source and -javadoc jar files using your platform classifier, to -mac-source and -mac-javadoc (or win, or linux based on your platform). Do this for the different JavaFX modules:

image

Back to NetBeans, check that now you have JavaDoc, or if you press Ctrl/CMD+Click you can access the source.

image

Note that this fix has to be done only once, the rest of your Maven projects should pick JavaDoc and Sources.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...