Git Product home page Git Product logo

openjfx-docs's People

Contributors

aadamvanko avatar aalmiray avatar abhinayagarwal avatar airsquared avatar cruciformhawk7 avatar dfm7 avatar djviking avatar erwin1 avatar ganapathi004 avatar gluon-bot avatar jdneo avatar jgneff avatar johanvos avatar jperedadnr avatar mkroening avatar slackuj avatar tiainen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openjfx-docs's Issues

Add a license

There is no license added to the repo nor to the docs

JavaFX with Intellij

I was following instructions on .... Non-modular projects ( IDE )
I did everything exactly as mentioned and i still get error when i run the application.

Error:(3, 26) java: cannot access javafx.application.Application
  bad class file: C:\Program Files\Java\OpenJDK\javafx-sdk-11.0.1\lib\javafx.graphics.jar(javafx/application/Application.class)
    class file has wrong version 54.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

macOS, JavaFX 11.0.1: QuantumRenderer: no suitable pipeline found

I am using Java 11.0.1 + JavaFX 11.0.1. I follow the sample

https://openjfx.io/openjfx-docs/#install-javafx

and it works just fine on Windows + Linux (Ubuntu 1810, Fedora 29).

On macOS 10.14, javac runs OK as well, but when i try to start the program (java -p /my/path/to/javafx-sdk-11/lib/ --add-modules=javafx.controls HelloFX) gives this error:

Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
...
Caused by: java.lang.RuntimeException: No toolkit found
	at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)

Adding javafx.graphics as well does not help.


I tried this sample two months ago on macOS with JavaFX 11.0 (not 11.0.1) and it worked! So this problem somehow seems to be new in 11.0.1.


Full error message:

Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:222)
	at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
	at java.base/java.lang.Thread.run(Thread.java:834)
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: No toolkit found
	at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	... 5 more

Analyse about links and highlighting in the tutorial

In my point of view highlighting or links should be a instrument to show the reader here is something special. In case from the links the interested reader have the option to follow the link for additional information.

To avoid in a technical guide to highlight or link every second word here a little convention which I will use to analyse the guide.

Links:

  • There shouldn't be more then 3 links in a sentence.
  • A keyword which is link shouldn't link again in the same chapter, section.

Highlighing:

  • There shouldn't be more then 3 highlighting in a sentence.
  • A keyword which is highlighted shouldn't highlighted again in the same chapter, section.

For example keywords for links in context from 'Getting Started with JavaFX 11' can be:

  • JavaFX 11, JDK, Maven, NetBeans, Gradle...

and keywords for highlighting:

  • JAVA_HOME, javafx.graphics, javafx.controls...

Next steps:

  • I will do the analyse from the tutorial pages :)

JavaFX and intellij

when i run javafx sample i get this error

Error:(3, 26) java: cannot access javafx.application.Application
  bad class file: C:\Program Files\Java\OpenJDK\javafx-sdk-11.0.1\lib\javafx.graphics.jar(javafx/application/Application.class)
    class file has wrong version 54.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

and when i go to Project Structure > Project/Modules the JDK is set to JDK11
VM option : --module-path C:\Program Files\Java\OpenJDK\javafx-sdk-11.0.1\lib --add-modules=javafx.controls,javafx.fxml

I tried to go to Settings > Build, Execution, Deployment > Compiler > Java Compiler
Project bytecode version was set to 8 and i changed it to 11 and the first error was gone but i got new error
Error:java: invalid target release: 11
I was searching on the internet and somebody said go to .idea\compiler.xml and set target to 11 but it's already set to 11 for me but i get the error

Intellij Run Config -> VM options path

JavaFX and Intellij
-> Modular projects
--> 5. Add VM Options (Windows)
This didn't work for me:
--module-path "%PATH_TO_FX%;mods\production"
This worked:
--module-path "${PATH_TO_FX};mods\production"
i.e. same as linux. Not sure if this has to do with Intellij version or bitness.

Tooltip Error in Firefox tab - shows tag 'span'

Moving the cursor over the tab in Firefox shows the tag 'span' in the Tooltip.

I don't know if it is an error in Firefox or in the styling from the title in the page 'index.html'. What is the reason that the '11' is betwenn the 'span' tags in the title?

tooltip-error_in_firefox-tab

Missing 'tags' in the GitHub project openjfx/docs.

Missing 'tags' in the GitHub project openjfx/docs.
In openjfx/samples following tags are used:

  • openjfx
  • javafx
  • javafx-11
  • java
  • java-11
  • examples
  • documentation
  • maven
  • gradle
  • netbeans
  • intellij
  • eclipse
  • modular
  • ide
  • non-modular

JavaFX 11 + jGRASP: "Runtime components are missing"

I'm trying to install and run JavaFX 11 to work with JDK 11 on a Windows 10 machine using jGRASP 2.

I've been following the "Getting Started" directions (https://openjfx.io/openjfx-docs/) as well as I can, given that there isn't a set of directions for jGRASP. I'm trying to compile and run HelloFX.java in the directions.

I've downloaded the ZIP and unpacked the JAR files, added the necessary JARs to the classpath, and added the following flags both to the compile and runtime commands, as instructed:

--module-path` "C:\Program Files\Java\javafx-sdk-11.0.2\lib" --add-modules=javafx.controls,javafx.fxml

HelloFX.java will compile successfully. However, when I try to run it, I get the familiar error message:

Error: JavaFX runtime components are missing, and are required to run this application

The "Getting Started" document says that I can fix that problem by including the --module-path and --add-modules flags above. But I've already done that, in both places. I'm at a loss as to how to proceed.

(No, I don't know how to use maven, or IntelliJ, or NetBeans, or Eclipse.)

Update jar task with compileClasspath in gradle projects

The gradle projects that include the jar task to create a fat jar use configurations.compile. With the recent version of the JavaFX plugin, dependencies use implementation instead of compile, so the configurations.compile doesn't include them anymore.

Changing to configurations.compileClasspath fixes the issue.

Eclipse with Gradle and Modular project shouldn't require JavaFX SDK

There is an issue with Eclipse, running Gradle and modular projects: the JavaFX modules are not added to the module path, but to the class path. When running if fails with module not found.

The workaround we have documented is to download JavaFX SDK and add it as a library, which shouldn't be necessary at all.

There is a better fix using the eclipse plugin, and moving "manually" the modules to the modular path.

WebView fails to create

Hello,

I try to migrate my project from the commercial Oracle JDK to the OpenJDK. I use the OpenJDK 11 and OpenJFX 11.0.1. When I try to create a new WebView object

view = new WebView();

program ends with th following exception:

Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.sg.prism.web.NGWebView (in unnamed module @0x3fc77788) cannot access class com.sun.javafx.sg.prism.NGGroup (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module @0x3fc77788
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

Navigation items with children do not change url

When an entry on the navigation tree is clicked, the URL should change with the hash-tag of the entry. This works with single entry but fails with entries which have a child navigation tree.

For example, navigating to https://openjfx.io/openjfx-docs/#modular takes you to "Runtime Images" section but if you have just landed on https://openjfx.io/openjfx-docs/ and clicks on "Runtime Images", it doesn't change the url.

The reason behind this is that the default action of the link is consumed:

$(".list-group-item .ref-group").click(function(e) {
    e.preventDefault(); // <------- Here
    var $target = $(this).closest('li').find("ul.list-group-sub").slideToggle();
    $('html,body').scrollTop(0);
    $('ul.list-group-sub').not($target).slideUp();
});

paths with spaces and modular/command_line section (win) | installation dirs for JavaFX

https://openjfx.io/openjfx-docs/#install-javafx
examples with Windows tab (Win 7)

note 1:
[Runtime images/Modular from CLI]
[Command Line]
dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX% -d mods/hellofx @sources.txt & del sources.txt

If there is path with space in name, sources.txt must be (manually) edited and corrected with quotes "" for each path and\replaced with \\

note 2:
This command (in the same section), works only without quotes ""
(I have path with space in name)
java --module-path "%PATH_TO_FX%;mods" -m hellofx/hellofx.HelloFX
correct:
java --module-path %PATH_TO_FX%;mods -m hellofx/hellofx.HelloFX

same this next
[jlink]
jlink --module-path "%PATH_TO_FX_MODS%;mods" --add-modules=hellofx --output hellofx

notice:
[Run HelloWorld using JavaFX 11]
set PATH_TO_FX="path\to\javafx-sdk-11.0.2\lib"
defines variable with quotes "" yet !

note 3:
When I installed JavaFX 11, first I intuitive copy JavaFX files to Java SE dirs, because there is files with same names and directories.
When I try compile and run sample HelloFX then it throws exception:
Error occurred during initialization of boot layer java.lang.LayerInstantiationException: Package jdk.internal.jimage.decompressor in both module java.base and module jrt.fs

When I remove ..lib\jrt-fs.jar from original Java installation it works, but I don't know if it is problem somewhere other.
Then I restore original Java SE installation and copy JavaFX-sdk and JavaFX-jmods to separated dirs, out of Java SE dirs, and it works.
But installation help needs to explicitly say about right way of installation.

Add a How to create JDK+FX section to the modular section

The modular doc should have different sections visible from the side bar:

  • Command Line
  • Maven
  • Gradle
  • Non-modular application
  • JDK+FX

The section should cover how to create a JDK that includes JavaFX and how that can be used for local development of regular JavaFX projects

Add how-to for deployment

Add a section that explains how to deploy a JavaFX application.

Some points to consider:

  • Main-class that doesn't extend Application (for now)
  • Building a (runnable) jar or fat-jar including JavaFX using Maven / Gradle
  • Cross-platform by adding classifier in Maven / something equivalent in Gradle
  • Modular vs non-modular JavaFX application

See: javafxports/openjdk-jfx#236

Getting Started with Gradle: Avoid using internal APIs

The current example shows the usage of internal Gradle APIs to compute the value of a platform Script variable. It would be better to use public APIs or a plugin to resolve this value as Gradle may remove/change internal APIs at any given time.

Usage of 'target="_blank" in 'href' tag.

Usage of 'target="_blank" in 'href' tag.

Article https://mathiasbynens.github.io/rel-noopener/.
They recommend in the article to avoid the 'target="_blank"' flag.

Clicking the above link opens malicious.html in a new tab (using target=_blank). By itself, that’s not very exciting.

However, the malicious.html document in this new tab has a window.opener which points to the window of the HTML document you’re viewing right now, i.e. index.html.

This means that once the user clicks the link, malicious.html has full control over this document’s window object!

When 'target="_blank"' is used, they recommend to add the additional "rel=noopener" flag.

To prevent pages from abusing window.opener, use rel=noopener. This ensures window.opener is null in Chrome 49 & Opera 36, Firefox 52, Desktop Safari 10.1+, and iOS Safari 10.3+.

Add section for jpackager

There should be a section how to use the jpackager to create runtime images and native installers.

  1. Download the latest JavaFX 11 backported jpackager
    http://download2.gluonhq.com/jpackager/11/jdk.packager-linux.zip
    http://download2.gluonhq.com/jpackager/11/jdk.packager-osx.zip
    http://download2.gluonhq.com/jpackager/11/jdk.packager-windows.zip

  2. Create a Gradle jpackager task

jpackager create-image
Generates an application image.

jpackager create-installer
Generates an application installer.

This is an example of how I am using the jpackager in Gradle:

mainClassName = "$moduleName/com.company.MyApplication"

task createInstaller(type: Exec) {
    dependsOn installDist

    commandLine '/usr/java/jpackager/jpackager', 'create-installer',
        '--name', project.name,
        '--version', project.version,
        '--description', project.description,
        '--vendor', "Company Inc",
        '--install-dir', "/opt/company",
        '--category', "Some/Category/Application",
        '--module-path', new File(installDist.outputs.files.singleFile, "lib"),
        '--module', "${mainClassName}",
        '--output', "$buildDir/jfx/native"
}

For a Non-Modular project:
Use JLink to create the runtime image, then use that runtime with jpackager.

task createInstaller(type: Exec) {
    dependsOn installDist
    dependsOn jlink

    commandLine '/usr/java/jpackager/jpackager', 'create-installer',
        '--name', project.name,
        '--version', project.version,
        '--description', project.description,
        '--vendor', "Company Inc",
        '--install-dir', "/opt/company",
        '--category', "Some/Category/Application",
        '--main-jar', jar.outputs.files.singleFile,
        '--runtime-image', 'runtime'
        '--input', new File(installDist.outputs.files.singleFile, "lib"),
        '--output', "$buildDir/jfx/native"
}

Gradle 5.0 is out. Pointing to it or let 4.10+ in the page "Run HelloWorld using Gradle"

Gradle 5.0 (https://jaxenter.com/gradle-5-152369.html) is out.

In the page "Run HelloWorld using Gradle" the note points to 4.10+.

  • Should the version for gradle wrapped into 'span class=GRADLE_VERSION' into js/gluon.js (var GRADLE_VERSION = "5.0";)?
  • Then the note can rebuild to some like "Make sure to use gradle version <span class="GRADLE_VERSION">5.0</span>+ and set the JAVA_HOME environment variable to JDK <span class="JDK_MAJOR">11</span>."

The javafx-gradle-plugin points to gradle-4.10.2-all.zip.

JavaFX libs are not in libs folder after running jlink

After following the directions under "JavaFX and Netbeans -> Modular from IDE", the application builds and jlink runs successfully, but I get the "Error initializing QuantumRenderer: no suitable pipeline found" error due to the JavaFX libs (in my case Mac *.dylib files) not being in the jlink'ed lib directory. If I manually copy them to that dir, the application runs. Suggestions?

Getting started instructions for modular NetBeans project produce an invalid image

I have followed the instructions contained in the getting started page, creating a modular project in Netbeans ("Modular from IDE" section).
In particular, I have followed the instructions contained in Section 6 to add the JavaFX jmods to the module path, but it seems that the jmods have not been used to create the image. When I run it, I get the error on the initialisation of the quantum renderer.
The output of the Ant build file is also suspicious, because it mentions the JavaFX jars instead of the jmods:

To run this application from the command line without Ant, try:
C:\Program Files\Java\jdk-11.0.1/bin/java -modulepath C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.graphics.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.web.jar;C:\Users\VTorroni\OneDrive - Serco\SW Projects\_libs\jexcelapi-2.6.12\modules\jxl.jar;C:\Users\VTorroni\Documents\NetBeansProjects\CryoStats\build\modules;C:\Program Files\Java\javafx-jmods-11.0.1 cryostats.CryoStats
deploy:
jar:
BUILD SUCCESSFUL (total time: 10 seconds)

If I follow the instructions for Eclipse, the image runs fine. The difference between the two images is that the image generated by NetBeans does not contain the following files:

  • decora_sse.dll
  • glass.dll
  • javafx_font.dll
  • javafx_iio.dll
  • prism_common.dll
  • prism_d3d.dll
  • prism_sw.dll

Add support for ogg audio on webview

This was a request since JavaFX 8. I know some will say that ogg is old, but mp3 is old too. Ogg audio is a better format for streaming and can be used in lower bit rates than mp3 with higher quality when compared with same bit rate on mp3. It is a open format. It have a wide usage on Linux platform. Please, add support for it.

Provide example for Gradle/Java Modules/JavaFx(.fxml)/Kotlin

I have been struggling for several weeks (!) to get a previously working JavaFX application to build and run in a clean manner using:

  • The current version of JavaFX (including use of .fxml resource files)
  • Java 9 modules (a module for the project as a whole, plus references to modules for including referenced libraries such as JavaFX)
  • A current version of Gradle (with a gradle script written using the Kotlin DSL syntax).
  • Some Kotlin code in the project itself (my project is a Kotlin/Java hybrid gradually being translated to Kotlin over time).
  • I am using IntelliJ Idea, although a command-line-only solution would be fine as a starting point.

I have encountered severe problems doing this, and at this point I have tried almost every idea I had as to how to accomplish it. Much googling has located for me a variety of fragments of Gradle scripts that accomplish one or two of these goals at a time, but which invariably are structured in such a way as to make the other goals difficult or impossible.

This should not be as difficult as it is, but lack of examples that use these items TOGETHER in a straightforward manner has made it an incredibly frustrating experience. For instance:

  • Most Gradle scripts I have found don't provide a way to put .fxml resource files into a place where the Java runtime can later find them using its existing getClass().getResource("foobar.fxml") calls. The JavaFX instructions do not appear to address this question.
  • Most Gradle scripts don't specify how to use JavaFX JAR files in conjuction with a Java 9 or later modular program, particularly with regards to --module-path, --add-modules, etc. on the command line that may need to be supplied when building or running a Java 9 JavaFX app.
  • Most Gradle scripts don't specify how to invoke jlink for a project that uses Java 9 modules in conjunction with JavaFX JAR files in order to produce a final executable that doesn't depend on an installed JDK,
  • Most Gradle scripts that use JavaFX jar files attempt to have Gradle automatically download the jar files itself (unlike the examples for openjfx at https://openjfx.io/openjfx-docs/#IDE-Intellij, which for some odd reason expects the user to manually download them). Thus, the "official" example scripts used on the JavaFX site are using a very non-typical way to access library files such as JavaFX JARs, which is not the way that Groovy or Maven typically do it.
  • Most Gradle scripts don't use Kotlin DSL syntax (now the "standard" way to use Gradle for Android projects, and increasingly popular), which means that even trying to adapt them to work first forces the user to translate them from Groovy syntax into Kotlin syntax before anything else can be done with them. This translation is often not trivial! Note that the examples given on the JavaFX pages such as https://openjfx.io/openjfx-docs/#IDE-Intellij do not currently show Kotlin Gradle syntax.
  • Some Gradle scripts use third-party JavaFX plugins such as https://github.com/FibreFoX/javafx-gradle-plugin, but these plugins are not clearly documented, and it is unclear how to accomplish some of the other goals listed above while using it.

and so forth. Each of the above observations has involved many hours of googling and experimenting on my part to discover what was going on.

Granted, some of these are Gradle problems, and I will be filing some bug reports against Gradle in the near future, but at the same time, I have found that the documentation for how to use JavaFX with Gradle seems to be very lacking with regards to how to use the two together. Example scripts that use up-to-date JavaFX practices use out-of-date or deprecated Gradle practices, and vice versa. Assumptions are made as to whether or not .fxml files will be used in the project, whether Kotlin will be used, and so forth. This lack of good, clean, simple, complete, and well-supported examples is a severe impediment to using both Gradle and JavaFX.

I have scoured the internet searching for a single example that works and incorporates all of these items together and have so far not found a single one. I am hoping that someone on the JavaFX team who is more knowledgeable than I with JavaFX can provide some examples on the "Getting Started with JavaFX 11" page that will accomplish most if not all of these goals in a single self-consistent script.

My current code, which SOMEWHAT works, and which can perhaps be used as a starting point for documentation or can be mined for ideas, is as follows:

	import org.apache.tools.ant.types.resources.JavaResource
	import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
	import org.gradle.internal.os.OperatingSystem
	
	plugins {
	    java
	    kotlin("jvm") version "1.2.51"
	    application
	}
	
	application {
	    group = "org.example.something"
	    version = "1.0-SNAPSHOT"
	    applicationName = "Something"
	    mainClassName = "org.example.something.Something"
	}
	
	// Note: OperatingSystem is a non-public Gradle API. I am using it here to avoid having to include an
	// external plugin to determine the operating system, such as com.google.osdetector. Personally,
	// I think that Gradle's OperatingSystem should be made public, and should include an instance method
	// for getting the platform name in a format suitable for use with JavaFX Jars (like the following)
	// so that using JavaFX with Gradle is simplified. There are already too many hurdles to jump through
	// in order to get JavaFX to work with Gradle.
	val os = OperatingSystem.current()!!
	val platform = when { os.isWindows -> "win"; os.isLinux-> "linux"; os.isMacOsX -> "mac"; else -> error("Unknown OS") }
	
	repositories {
	    jcenter()
	}
	
	dependencies {
	    implementation(kotlin("stdlib-jdk8"))
	    implementation("org.openjfx:javafx-fxml:11:$platform")
	    implementation("org.openjfx:javafx-web:11:$platform")
	    implementation("org.openjfx:javafx-media:11:$platform")
	    implementation("org.openjfx:javafx-swing:11:$platform")
	    implementation("org.openjfx:javafx-base:11:$platform")
	    implementation("org.openjfx:javafx-graphics:11:$platform")
	    implementation("org.openjfx:javafx-controls:11:$platform")
	    // other implementation dependencies go here...
	}
	
	configure<JavaPluginConvention> {
	    sourceCompatibility = JavaVersion.VERSION_1_10
	    targetCompatibility = JavaVersion.VERSION_1_10
	}
	
	// Put *.fxml files from src/main/java into a 'resources' subtree instead of alongside *.class files.
	// This is necessary because Gradle won't copy them from the subtree containing class files into
	// a location where getClass().getResource(...) can find them at runtime.
	sourceSets {
	    getByName("main") {
	        resources {
	            srcDir(files("src/main/java"))
	//            outputDir = file("java") // Is this needed or helpful?
	        }
	    }
	}
	
	// The name of the top-level module (target module) we are building.
	val moduleName = "org.example.something"
	
	// This task will compile all Java code in the target module except for test code.
	// Note that we are supplying a module path (from the 'dependencies' section above) instead of
	// a class path to the Java compiler.
	tasks.named<JavaCompile>("compileJava") {
	    inputs.property("moduleName", moduleName)
	    doFirst {
	        val modulePath = classpath.asPath
	        classpath = files() // Clear classpath since we are using module path instead
	        options.compilerArgs.addAll(listOf(
	            "--module-path", modulePath // Supply accumulated class path as module path instead.
	        ))
	    }
	}
	
	// This task will compile all Java test code in the target module.
	// Note that we are supplying a module path (from the 'dependencies' section above) instead of
	// a class path to the Java compiler.
	tasks.named<JavaCompile>("compileTestJava") {
	    // See https://stackoverflow.com/questions/46991022/junit-5-java-9-and-gradle-how-to-pass-add-modules
	    inputs.property("moduleName", moduleName)
	    doFirst {
	        val modulePath = classpath.asPath
	        classpath = files() // Clear classpath since we are using module path instead
	        options.compilerArgs.addAll(listOf(
	            "--module-path", modulePath // Supply accumulated class path as module path instead.
	        ))
	    }
	}
	
	// This task will compile all Kotlin code found in the Java source tree.
	tasks.withType<KotlinCompile> {
	    // See https://stackoverflow.com/questions/47657755/building-a-kotlin-java-9-project-with-gradle/47669720#47669720
	    destinationDir = tasks.withType<JavaCompile>().first().destinationDir // Use same dir for Kotlin classes as Java classes.
	    kotlinOptions.jvmTarget = "1.8"
	}
	
	// This task will run the JavaFX version of the app.
	// In addition to supply ing the module path, we need to patch the top-level module to
	// include the resources directory (where .fxml files will be located) so they can be found
	// at runtime.
	tasks.named<JavaExec>("run") {
	    doFirst {
	        val modulePath = classpath.asPath
	        jvmArgs = listOf(
	            "--module-path", modulePath,
	            "--add-modules", "ALL-MODULE-PATH",
	            "--patch-module", "$moduleName=build/resources/main",
	            "--module", "$moduleName/${application.mainClassName}"
	        )
	    }
	}

In summary, please modify your "Getting Started With JavaFX 11" examples page to provide a working example of a Gradle script that accomplishes these goals. Basically, I would like to see a "Hello, World" that is implemented using idiomatic Gradle, Kotlin, Java 9 modules, and JavaFX with .fxml files.

Thanks in advance.

Linux/Mac-Windows tabs selection doesn't work

There Linux/Mac tab should be preselected, as the code shows the Linux/Mac configuration. And all the tabs from all the docs should use that preselection. When the user changes it, all tabs should change as well.

Somehow this is broken now.

Simplify OS detection

Currently, almost a third of the sample build.gradle script is doing OS detection. Why not simplify things? The same can be achieved by

def osName = System.getProperty("os.name").toLowerCase()
ext.platform = osName.contains("mac") ? 'mac' : osName.contains("win") ? 'win' : osName;

Or does the osdetector anything special related to Android and iOS?

The problem here is that people starting with JavaFX & Gradle often use copy & paste to create their first build script or update JavaFX projects to Java 11. And they'd have to merge potential buildscript {..} blocks from other gradle scripts even though it's not really needed.

I can't get javafx to run on my computer

I followed the getting started with eclipse to the best of my ability. however I keep getting this error when I try to run the gui class.

Error: Could not find or load main class Files\Java\javafx-sdk-11.0.2\lib
Caused by: java.lang.ClassNotFoundException: Files\Java\javafx-sdk-11.0.2\lib

any help would be very much appreciated! thanks

Not compile samples, for IDE non-modular-gradle

For JavaFX and IntelliJ -> Non-modular with Gradle

Task :compileJava FAILED
E:\projects\appFx\src\main\java\org\openjfx\FXMLController.java:5: error: package javafx.event does not exist import javafx.event.ActionEvent;

I guess incorrect build.gradle:

dependencies {
    /* uncomment for cross-platform jar: */
//    compile "org.openjfx:javafx-graphics:11:win"
//    compile "org.openjfx:javafx-graphics:11:linux"
//    compile "org.openjfx:javafx-graphics:11:mac"
}

The docs for non-module apps could be improved.

Currently the recommendation on the web site if your app is non-modular is to throw everything out and not even use jlink or modules at all. That seems extreme to me and not really desirable. Why not explain how to use jlink to create a runtime that includes the JavaFX modules and at the same time launch your application as a normal executable jar using the classpath for non-modular dependencies and the module path (or jlink the modules into the runtime) for modular dependencies?
Since at this stage it is still nearly impossible to make a reasonably complex application without running into at least one non-modular dependency, I would think this is a common need.
This would also avoid the need to make a separate non-Application main class or the hideous practice of creating a fat jar.

Review from the 'Getting Started with JavaFX 11'

Hi there,
first I want to ask you if I can contribute to your greate project?
I have read the tutorial and some points I notice some points aren't clear for me or where I thing why is that so?

So my suggestion is that I will add here for every point a commentary is that for your okay (or should I do a list from points which can then chopped?).

How to add javadoc in Netbeans

After getting most of the things up and running with Java11 there is one thing I still haven't figure out: how can I attach javadoc for JavaFX11 in Netbeans?

For OpenJDK 11 it worked with adding https://docs.oracle.com/en/java/javase/11/docs/api in the platform manager. But I haven't found any documentation on how to do it for JavaFX...

Any pointers are appreciated,
Thomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.