JAVAFX not being picked up in runtime from Spring STS with Java 8 on Mac - javafx

I've installed Java 8 and Spring STS on Mac. Running jjs from the command line works. However, when trying to create a new class in a Maven project in STS, the editor doesn't recognise the javafx.* package automatically.
Attached you'll find an example of an image showing that the only Label object suggested is the java.awt one.
Any idea on how I could solve this?
Regards,
M.

I think this is related to the settings of your project. If your project is created with an execution environment JavaSE-1.8, this execution environment doesn't have the javafx API defined as accessible and you would need to manually allow that. If you choose the 1.8 JRE (as a JRE, not an execution environment) in your project settings, the JavaFX API is accessible and works nicely in content-assist, quick fix, etc. This is at least the case if you create a standard Java project.

Related

Unable to create a JavaFX project in Netbeans IDE 16 [duplicate]

I've been banging my head on this one for ages and all of the tutorials I've found don't seem to work. When I try to create a new JavaFX project in Netbeans 14, using JDK 18 and the latest JFX download for Windows here:
https://gluonhq.com/products/javafx/
Also tried with JDK and JFX 17 and still no luck. I get this error:
I've added the libraries like so:
If I try to add the platform folder, it won't let me progress through the dialogue:
I can't find solutions to this anywhere and, again this is the same with JDK 17 and 18, and JFX 17 and 18. I've checked the documentation and there's nothing that seems to solve the issue.
It says to go to the JavaFX tab and enable JavaFX, but there's no JavaFX tab... Unless they mean this:
But if that's it then, as you can see, it's already enabled and it's still not working. I'm totally lost. I don't understand why the documentation is so poor for FX, for every IDE. It's honestly like they don't want people to use it and every tutorial I'm finding is using outdated versions of NetBeans, the JDK and JFX D-: (they also don't solve the issue even if I do follow them).
If anyone could help guide me, I'd really appreciate it.
I would suggest you go to New Project -> Java with Maven -> either Simple JavaFX Maven Archetype(Gluon) or FXML JavaFX Maven Archetype(Gluon). Use the POM to change your version of JavaFX from the default to whatever version you like. I also use the POM to change the JavaFX-Maven-Plugin to the latest version.
I strongly endorse the approach using maven suggested here. This project started exactly the same way; I'd welcome learning of any issues you encounter.
Alternatively, follow the steps outlined in JavaFX and NetBeans: Non-modular projects: IDE. You've created a JavaFX library, but "Don't try to create a JavaFX project." Instead, choose Java with Ant and Java Application to create a new project, shown below, then follow the remaining steps carefully. It's a convenient alternative for a scratch project while you assay maven.
Addendum: The ant code for a JavaFX project, not selected in the image above, may attempt to package dependencies that are no longer required. In particular, a project using module javafx.web may fail with the following error, seen here and here. The easiest fix is to recreate the Java application by choosing Java Project with Existing Sources.
Unable to create javax script engine for javascript.
Alternatively, a simple example using a custom ant script is cited here.

BROWSER option is missing in view listener in a tree in JMeter

I have JDK 14 and JMeter 5.3 configured on my Windows 64 bit system But I don't see "Browser" option in "View Listeners in a Tree" in JMeter.
Any ways I can get it?
The easiest solution is just to downgrade to Oracle JDK 8 as it includes JavaFX package which is required for this Browser option to work.
However according to 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure you should always be using the latest version of JRE/JMeter so if you need to be able to render the response in the View Results Tree listener go for the following steps:
Download and install OpenJFX
Set PATH_TO_FX environment variable pointing to the OpenJFX installation folder
Restart JMeter - at this point you should see the Browser option
Browser option was removed due to missing JavaFX suppport
Bug 63355 - View Results Tree: Browser view option is not Available with Java 11
You can downgrade to Java 8 (which include library) or add Java FX library manually
Felix Schumacher:
You either have to downgrade to a Oracle Java -- which includes JavaFX, or you try to integrate JavaFX into a newer Java version. openjfx.io claims to have JavaFX versions for newer Java versions.

How to add javafx environment variable in Ubuntu now that the Oracle removed javafx from JDK?

I recently started learning javafx but now I came to know it was removed from the core JDK since java 11. I can't seem to find a way to compile javafx application. The import declaration is not working (I am using MVC design pattern). Is there a way to get around this?
I am using VS Code
Starting with Java 9, JavaFX was moved out of the JDK so that updates to JavaFX did not have to wait on the next JDK release (at least that's what I remember). When Ubuntu switched to JDK 11 from JDK 8, they added a new package "openjfx" that provides the JavaFX libraries.
So you have a couple of options to use JavaFX.
Install OpenJFX
sudo apt install openjfx libopenjfx-java
Setup Gradle Build
If you are using gradle to build, you can set it up to download whatever JavaFX version you want. Follow the instructions from openjfx for setting up a basic gradle configuration. The linked page has an example file you can start with.
You may also want to consider using Intellij Idea Community edition IDE instead of VS Code. I think VS Code is excellent and have used it for a couple of years now including for JavaFX development. I recently switched to Intellij and the features it provides for java development are step above VS Code. Plus it's provided as a snap so easy to install:
snap install intellij-idea-community --classic
So, about the environment variable. I'm guessing you are on Linux, so you have two ways of setting it:
A) set it for current session;
B) set it globally.
Option A: open the Terminal and execute export PATH_TO_FX=[absolute path to Javafx folder]/lib. This will create a variable for your current user for the current session only - you will have to execute it every time you boot your OS.
Option B: locate the file /etc/profile; then back it up; then open it for editing and add the export PATH_TO_FX="[absolute path to Javafx folder]/lib" line to the end of it. Save the file and restart your system. This way the variable will be preserved for all users permanently.
Finally, test the Javafx presence by launching your application jar - java -jar --module-path $PATH_TO_FX --add-modules javafx.controls,javafx.fxml your.jar (or launch your main class as shown in the documentation).

How to set application name at runtime

Whether I run my JavaFX application in the IDE or build and run the .jar, the application's name showing in the toolbar is basically the Main class :
I tried to build the artifact with IntelliJ and also with Maven ($ mvn clean package), but same result for both. I'm using JDK8 on Ubuntu.
Is there a way to change the application name/title?
Thanks.
As far as I know there is no programmatic way to set the application name in JavaFX. This can however be done when you package your application via the new jpackage tool (JDK 14).

Stuck with creating Keyword library using Java in Eclipse and using that JAR file in RIDE

I'm new to ROBOT framework and must create library keyword using java and utilize the JAR files in RIDE editor. I have followed the below steps. But still have confusions in where to start up. Please help me to achieve this.
Steps:
1) Installed Python, wxPython, pybot, RIDE, selenium2library successfully and I'm able to work with RIDE using predefined keywords.
2) For creating own java library, Installed Eclipse Mars, Java, ROBOT IDE manually using the link https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Installation
The question here is,
Anything i'm missing to install?
How to proceed further with Robot Framework coding?
Note: I'm reading many materials in parts to proceed things. But that is confusing me what are the steps to be followed. Is there any single material that i can get having the sequences of steps that need to be followed for my requirements?
The below links I referred with,
https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Usage
Maven error "Failure to transfer..."
Create a Maven project in Eclipse complains "Could not resolve archetype"
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-set-test-suite-global-variable-keywords
Let's start with the basics. RIDE is an editor for Robot Script files. Robot Script files are executed by the Robot Framework robot application. It is important to understand the difference between these two applications. One creates files and the other uses them.
Assuming for a moment here that you have some custom functionality in a Jar file that you would like to make available inside the Robot Script files test cases. If this is indeed the case then your focus should be on create Robot Test Libraries. In the documentation there are numerous java examples given for basing your own library on.
This means that you do not need Maven, unless you want to, to create your library. Also Eclipse IDE is not needed nor is RIDE. The library you create can be used by Robot Framework even when it's run from the command line. Feel free to use them for what they are good at: writing Robot Scripts efficiently and running Robot through menu options instead of command line windows.
When you are familiar with Eclipse and comfortable with it's features, then I can also recommend using the Eclipse Application RED which is a mature Eclipse add on for creating, running and debugging Robot scripts.
There are two ways of implementing a Java routine in Robot Framework and it depends a bit on how you run Robot Framework: Python or Jython. Running Python means that you need to run the Java in a separate JVM container and connect to it. The simplest way is via Command Line interaction. This may cause some security concerns. The second approach is to use the Remote Library approach. A good example of this is the Robot Framework Sikuli Library. An added bonus is that you can run Robot and your Java application on two separate machines/servers.
The Jython way has been discussed on StackOverflow before and I gladly refer to it. Please bear in mind that although the examples refer to RIDE, the Library org.company.Keywordlibrary works in all IDE's, provided robot framework is run using Jython.
In the Jython documentation it clearly explains how to setup an Eclipse based IDE with Jython. Do keep in mind that it's recommended to use the same interpreter in development and production. I.e. if you create your scripts in Jython, do run them in 'production' also using Jython. Otherwise you open yourself up to interpreter differences where functionality does not work or behaves differently then expected.
An alternative approach with Jython is the all-in-one Robot Framework Maven JAR plugin. Adding a custom Java Library in this setup is not too difficult. A nice short tutorial can be found on the blog of Valerio Bruno. If this is your preferred route for development, then you may want to read the RED howto on integrating the Robot Framework Maven jar.
Working on your custom functionality is likely going to be a independent project in Eclipse, but can be linked to an Robot project via the Class Path settings in red.xml if you use RED or the CLASS_PATH environment variable.
Done! I have installed RED and required add on using following below steps. It worked successfully with predefined keywords. Now I'm gonna create user defined keywords/libraries using the same editor. I don't know where to start up. Will it work creating just a java project? Should I need to include any additional libraries?
Steps followed to proceed with RED:
1. RED Version Conclusion: https://github.com/nokia/RED/blob/master/release.md
2. RED Installation Instructions: https://github.com/nokia/RED/blob/master/installation.md
3. ROBOT Framework prerequisites using RED: https://github.com/nokia/RED/blob/master/red_help/first_steps/download_install.html.md
4. To verify Installations in Eclipse: Help -> Installation Details to check if RED is visible on installed features list
5. Create Project and Tests using RED in Eclipse: https://github.com/nokia/RED/blob/master/red_help/first_steps/create_run.html.md
6. RED Steps: https://github.com/nokia/RED/blob/master/First_steps.md
7. Quick STart: https://github.com/nokia/RED/blob/master/red_help/user_guide/quick_start.html.md

Resources