Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once you have downloaded and installed an IDE, you will need to configure it to the latest JDK version. This will be explained later on for each particular IDE. If you use an IDE without current support, OpenJFX will not compile and you will not be able to run from within the IDE.

...

JDK-

...

8 Only: Delete jfxrt.jar (or move it to a different directory)

JavaFX is bundled with the JDK as an extension. The jfxrt.jar is located in the extension directory called 'ext' where Java is installed. You must remove it from this directory for the IDE's to work properly. The issue is this: If jfxrt.jar is in the extension directory, it will get seen before the code in your IDE. This means you won't be running or testing the code in your IDE. For more information on why this is a problem, see Unique Challenges of Working on the JDK.

...

IMPORTANT:  Do not skip this step.  If you do, you will not be running the code in your IDE and will waste hours wondering why you make changes and they don't run.

Using NetBeans (JDK-8)

Many commiters are using NetBeans to develop Java and native code.  NetBeans projects have been configured for both.  Native projects in NetBeans are currently not configured to build using either Make or gradle, however ant build works in NetBeans and will build the classes and jar files needed for the IDE.

...

Eclipse is a popular IDE that is used by many committers to develop Java code. Eclipse projects project files and Buildship files (.project, .classpath, and files in the .settings folder) and have been created for you to useand checked into the repository. You should use the latest Eclipse version, or at least 4.8 due to modular support.

IMPORTANT: The location of the mercurial repository (<PATH TO JFX>) must not be inside the Eclipse workspace directory.  If it is, nothing will compile and work. (This might not be true anymore)

The steps to use Eclipse are:

  • Import the Eclipse Projects
  • Configure Eclipse to use the latest JDK
  • Run sample code
  • Run sample code with grade built shared libraries

a version that supports JDK N-1 (for OpenJFX N) after patching (see below on patching).

OpenJFX is built using Gradle, which uses the javac compiler (even when run through Eclipse), and uses the Gradle wrapper to specify its current version. Various tasks, such as testing, are also configured through Gradle. However, you can still use Eclipse's compiler (ECJ) to take advantage of its speed as an incremental compiler, and of Eclipse's faster unit tests runner. Gradle is mandatory for the following phases:

  • The initial setup (./gradlew or /.gradlew build) that generates resources that are needed for the build.
  • Verify that the build task is successful with javac (because Eclipse's compiler can give different results sometimes).
  • Running tests in the cases where Eclipse isn't configured to run them, or when the different compilers produce different results.

You can either use Gradle from the command line or through Buildship, which integrates Gradle into Eclipse (see below for more info on Buildship).

Import the Eclipse Projects

  1. Go to File -> Import -> General -> Existing Projects into Workspace.
  2. Set the root directory to the base repository path (/rt by named "jfx" be default).
  3. Check Search for nested projects.
  4. Optionally, you might find it convenient to work with Working Sets.
  5. It's recommended to import all the projects, however, you can select only the ones you know that you will need.
  6. Click Finish

(Picture out of date)Image Added

Organizing the Workspace

OpenJFX contains a large number of projects, which can make it difficult to work with as most of them will not be used regularly. Eclipse's Project Explorer view will show the projects' hierarchy:

Image Added

You can use this view to collapse the non-relevant projects. If you prefer to use the Package Explorer view, you can use Working sets to only show those you are interested in. For example, you can create a working set for the projects under "apps", another for those under "modules", and another for those under "tests".

You can also close projects, which can reduce some visual clutter and will save time when building, but you will have to make sure that there are no errors on any project before integrating a PR. If you know that some projects can't be affected by the area you work on, you can close them.

Using Buildship

Buildship is an optional plugin that integrates Gradle into Eclipse, allowing you to forgo the command line. If you choose to use Buildship, use the latest version, as the Gradle version used in OpenJFX updates from time to time and Buildship needs to support that Gradle version. As mentioned above, the Buildship files that are required for the projects' configuration are included in the repository.

The Gradle Tasks view will list all the tasks that are configured in OpenJFX.

Image Added

Not all Java projects are also Gradle projects. The root project ("jfx") is a Gradle project that configures some other child non-Gradle project (like the "base" project under "modules"). Some projects (like those under "tests/manual") are neither Gradle projects themselves, nor are they configured by the root project. There are 3 projects under "apps/samples" that are Gradle project themselves, but they do not function as such currently.

NOTE: Refreshing a Gradle project through Right Click → Gradle → Refresh Gradle Project will override the projects' Eclipse configuration files that come with the repository, and will cause them to not work anymore. This is because Gradle/Buildship does not know yet how to create the correct configuration files by itself. If you refresh a project by mistake, since we are using a git repository, we can revert the breaking changes. This is also the reason for not importing the projects as Gradle projects. It is safe to refresh tasks in the Gradle Tasks view.

Using EGit (TODO this section)

It's recommended that location of the local git repository not be inside the Eclipse workspace directory.Image Removed

Configure Eclipse to use the latest JDK

  1. Go to Window -> Preferences -> Java -> Installed JREs and Add → Standard VM and select point to the above latest version. If you want to find a regression or backport, you can switch to earlier versions here under Installed JREs (will require rebuilding). You might see a warning that Eclipse does not support this Java version, this should not cause issues.
  2. Go to Window -> Preferences -> Java -> Compiler→ Java → Compiler and set the compiler compliance level to the latest (you will . You might not have an option for an unreleased version of Java). . For example, if compliance level 11 is not available, install the patch from the update site: http://download.eclipse.org/eclipse/updates/4.9-P-builds/. Similarly, for Java 13 use: https://download.eclipse.org/eclipse/updates/4.13-P-builds.

Building the workspace can take some time. However, thanks to Eclipse's incremental compiler, you do not need to rebuild all of it on every change.

NOTE: Dialog.java in the controls module currently gives a compiler error because of a bug in Eclipse. It can be worked around be moving the erroneous line out of the lambda expression. Remember to ignore this change when working against a revision.

JUnit tests

Running Applications and JUnit tests

Eclipse can run the applications in the repository (under "apps" and "tests") regardless of Gradle. You will need to add the following VM arguments to the launch configuration:

-Djava.library.path="<path to repo>\modules\javafx.graphics\build\module-lib"

--add-modules=javafx.controls (or other modules that are required, like "fxml").

JUnit tests can also be run Eclipse can run JUnit tests as an alternative to the gradle Gradle tasks. Right click on the resource you want to test (project/package/class) and select Run as -> JUnit Test.→ JUnit Test. You might need to add the following VM arguments:

-Djava.library.path="<path to repo>\modules\javafx.graphics\build\module-lib"

-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit

When running test.javafx.scene.web.WebViewTest, use instead:

-Djava.library.path=<path to repo>/modules/javafx.graphics/build/module-lib:<path to repo>/modules/javafx.web/build/module-lib

Running a dependent project

Having an external project that uses the development OpenJFX modules is useful for debugging and testing.

...

Code Block
languagejava
titlemodule-info.java
linenumberstrue
collapsetrue
module zTesttest {
	requires javafx.base;
	requires javafx.graphics;
	requires javafx.controls;

	exports zTesttest;
}

In the project properties, Go go to Java Build Path -> Modulepath and add the required projects.

Write your classes.

If when running you receive warnning warnings about missing packages or modules, edit the run configuration by going to its Dependencies -> Override Dependencies, then delete the launch dependencies and Override.

Run Sample Code (NOTE: old)

Image Removed

Using Gradle

Eclipse has gradle support via Eclipse Buildship. Use the latest Buildship version as the gradle version used in OpenJFX updates from time to time. OpenJFX uses the gradle wrapper.

The project structure for gradle is such that the root directory (/rt) contains the parent project with all other projects being its children. The Gradle Tasks view will allow you to execute the tasks that you would use Cygwin for otherwise.

NOTE: this process will override the projects' configuration and will cause them to not work anymore. However, since we are inside a mercurial repository, we can revert the breaking changes and keep the gradle settings. This will allow us to work with both Eclipse and gradle.

  1. Install Buildship.
  2. Go to File -> Import -> Gradle -> Existing Gradle Projects.
  3. Set the root directory to the base repository path (/rt by default).
  4. Finish and wait for the workspace to rebuild. This will result in many compilation errors.

  5. Revert all .classpath files (and clean and rebuild if it does not happen automatically - this will some take time). There should be no compilation errors.

What this process does is add the gralde nature and build command to the .project files. This means that these files are now different than the ones in the repo. Additionally, the .settings folder for each project will contain a Buildship pref file. You will need to resolve the conflicts with the upstream repo, e.g., via hg ignore or hg forget.

Run Sample Code with Gradle Built Shared Libraries (Note: old)

//TODO - explain how to hook up the shared libraries in the run dialog

If when running you receive an error like:

Code Block
Graphics Device initialization failed for : d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found

Then add //TODO - these are the VM Arguments: -Djava.library.path=${workspace_loc:rt}/build/mac-sdk/rt/lib"<path to repo>\rt\modules\javafx.graphics\build\module-lib" to the VM arguments in the launch configuration.