Error setting up JavaFX on NetBeans despite VM options - java

I was following this tutorial to set up JavaFX on the Apache NetBeans IDE. I created the library as instructed and created the Controller.java and FXML files (literally just copy/pasted from the examples, along with the Main.java and HelloFX.java files; I wrote nothing of the code itself).
I tried the solution on step 5 for the JavaFX runtime components are missing, and are required to run this application error, but it just makes a new error pop up: java.lang.module.FindException: Module javafx.controls not found.
The directory the components are on is D:\Programas\javafx-sdk-13.0.2\lib, which I supplied as instructed (--module-path "D:\Programas\javafx-sdk-13.0.2\lib" --add-modules javafx.controls,javafx.fxml). I also tried setting an environment variable as instructed here and using that instead (--module-path $PATH_TO_FX$ --add-modules javafx.controls,javafx.fxml), to no avail.
I searched for solutions for a long time, but the questions either lack answers, or I just find the same tutorials over and over again, often for old versions of the Java SDK and/or NetBeans IDE.
I'm new to both JavaFX (I was learning Swing when I found out it's getting the boot) and the NetBeans IDE (I'm used to Eclipse), so I'm completely in the dark here.
EDIT: Added screenshot as requested.

I found an answer on GitHub that sort of worked. Here they say you can remove the VM arguments if you add the JavaFX library to the Run option in the libraries for the project, but I was only able to get everything to work by adding the library and keeping the VM arguments.

Related

Unable to access JDI classes in Eclipse project

I wanted to try writing my own Debugger but was not able to do so yet as I cannot get Eclipse to allow me to programmatically access any classes of the Java Debug Interface (JDI). At first, I thought I may have a problem with my installed JDK (JDK 15.0.2) but a test with a manually compiled and executed file which featured some code for launching a Java-VM in debug mode showed that the installation is fine, and the problem must have something to do with Eclipse. If I navigate to the jdk.jdi JAR located in the JRE System Library submenu of the package explorer of my project I can even see all of the classes I would need (LaunchingConnector, Bootstrap, MethodEntryRequest, etc.). I recreated the project a few times already and also tinkered with some Build Path settings but to no avail. I'm kind of lost as to what I should try next, so any help is much appreciated.
EDIT:
Thanks to #nitind for providing the answer. I simply had to remove the check mark for com.sun.* in the Type Filters preference page, then everything worked like a charm.

Using WindowBuilder in a Java Swing and JavaFX interoperability context seems to cause Eclipse to crash?

The problem: I strongly suspect WindowBuilder makes my Eclipse crashing under certain conditions. These conditions are:
the class you're working on it using the design tab has to contain some references to a JavaFX code
first time you design such class it's all good. Second time you click on design tab of another class of that kind, or click on "Reparse source and refresh design page" icon inside the design view of the first class, Eclipse crashes. Essentially, parsing the code of such classes for a second time is where it crashes.
My context: I'm coding a gui hangman game using Swing and JavaFX libs. I'm aware of the conditions for interoperability between these two guys.
I'm using Eclipse IDE for Java Developers Version: 2021-12 (4.22.0) (the current one the installer installs on your computer). The JDK 17.0.1 (installer on Oracle site for Windows x64) and I'm on Windows 10 x64.
Enviroment variables (JAVA_HOME and PATH_TO_FX) and Eclipse project settings (non modular project is my case) should be ok: my code is compiled, my program runs without troubles, I see the gui and everything is where it should be and working. But to be sure I've tried to reproduce the crash with the code of more experienced people of me for sure (article link, repository link) and it crashes in the same way. I'm gonna post my code if required of course.
I'm using WindowBuilder 1.9.8, the last good build, cause a bug me and other people have encountered (see here, here and here) has been fixed there. Anyway, it crashes even with previous versions.
I'm gonna post a bunch of additional info about logs and crash reports, please skip it to the end if you think there's no need of additional info.
I'm running Eclipse with the -consoleLog parameter in the .ini file to have the log in a shell window at runtime. This is the relevant part of the log once it ends to load Eclipse:
java.lang.Error: SWT Resource was not properly disposed
and this is what it says when I click on the design tab of a JavaFX referenced class:
com.sun.javafx.application.PlatformImpl startup WARNING: Unsupported
JavaFX configuration: classes were loaded from 'unnamed module
#3d79168b'
but as I said, my project settings should be ok: running configurations -> java application -> main class -> vm arguments:
--module-path ${PATH_TO_FX} --add-modules=javafx.graphics,javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.web,javafx.swing
Yes, I know there's no need to load all modules, but just to be sure. And yes, I've even read this, but seems like I'm getting this warning anyway.
When I click on the "Reparse source and refresh design page" icon inside the design view, It freezes and have to terminate the process. The crash report says:
"Java was started but returned exit code= -8053063696"
So I looked for it, found this, tried everything (even to unistall the jdk, eclipse including the .p2 folder), but still the same problem
When I try to open the design tab on another JavaFX related class the crash report is different:
"Java was started but returned exit code= 1"
So I've read this, but my enviroment variables should be properly setted and everything should be correctly installed. I've even edit the .ini file to add the reference to the Java Virtual Machine dll, but still the same problem.
My question: can you reproduce this crash? There's a fix or I'm doing something wrong?
p.s.
I'm getting the "Wait! Some of your past questions have not been well-received, and you're in danger of being blocked from asking any more." warning here on stackoverflow :( I've read this and I hope this question it's ok

Java decompiler plugin not working

I have the JD-eclipse-plugin installed. I want to decompile the classes within a jar-file. So I select the jar-file within Project-Explorer and click Decompiler in the Menu. However both decompilers (JAD and JD-core) are greyed out.
I also tried the steps shown in this blog on AVAJAVA Web Tutorials. I guess the blog is a bit outdated, however I can see within Windows-->Preferences-->Java-->Decompiler that Jad is correctly set up. But there is no JD-eclipse found within Preferences-->General-->Editors-->File Associations as you can see in the following image.. Now I right click the jar-file within Project-Explorer, but there is no such "Attach Source File".
Did I miss anything to set up the plugin?
EDIT: I´m using the following setup: Eclipse: Mars.1 Release (4.5.1); JadClipse 4.0.0; JDK 1.8
EDIT2: Forgot to mention that I use Tomcat and want to dive into the libraries from /WebContent/WEB-INF/lib. This is not working, I cannot further collapse the jar-files.
For Eclipse 2018-09 , the problem was related to " class without source
"
I had resolved this issue by going to:
Preferences
General
Editors
File Associations
Class without source
and setting decompliler viewer as default : see the following screen shot:
Obviously I mixed the actual JD-eclipse-plugin an a plugin called JadClipse for Eclipse which is a slightly different plugin from eclipse marketplace. Thus when I followed the installation instructions of JD-eclipse, I could set the options for the screenshot posted within the question. So I set JD-eclipse as default for both *.class-files with and those without source-code.
Second mistake I did was a pretty silly and obvious one, namely that I wanted to browse the jar-files from within WEB-INF-folder of my Tomcat instead of from within Java Resources. Thus I could not dive into the jar-files at all hindering me to get to the class-level and thus to decompile those classes contained within the jar.
I hope this helps anyone outside also having trouble with the plugin for eclipse.
I had the same problem but "class without source" did have decompliler viewer as default. So all I did was set class file viewer as default and then switched back and that fixed the issue.
I had to update all of my plugins. the Procyon decompiler has this symptom when running under java 11 or later.

Getting JavaFX to run via Browser for Simple HelloWorld app

I tried following various tutorials for getting a JavaFX hello world app running in a browser. I can't believe it's that hard, so I'm looking for any insight into what I may have done wrong. Some things I've tried and resolved (to rule out the obvious):
Had to download 32-bit JRE for the browsers and ensure they were using that
Thus using the latest JRE (7u21); running on Win 7 64-bit
Checked Windows Control Panel -> Programs -> Java to verify the JRE being used
Signed the JAR file
Tried running from local file, found that drive letters weren't recognized, so moved to running via Tomcat 6
Tried various changes to the codebase and url hrefs, but I believe those are correct.
Tried in both IE 10 and Chrome
What I ended up with was that loading the .html (which references the jnlp using the JavaFX default javascript) would spin for a while then fail. If I try to load the .jnlp file directly, I get an exception:
ClassNotFoundException: javafx.application.Application
I verified that the jfxrt.jar is in the lib folder of the JRE that the browser is using.
Any insight/suggestions as to what I may be missing at this point? Seems like it must be something obvious/basic at this point, but I'm not seeing it. Thanks.
Just to follow-up, I went ahead and used javafxpackager. That produced a web page that would load the JavaFX application in Chrome. However, it still doesn't work in IE. I'm going to write that off as an IE but since it works in Chrome. What I did learn by looking at the results, though, is there are several things javafxpackager does, and the results of that are not exactly what's described in most of the manual tutorials/examples. Minor differences, but apparently they matter.
It sounds as you don't have the JavaFX starter classes in your JAR (usually done by the Ant script) and don't have the correct JavaFX Manifest entries.
It should not be needed to add the jfxrt.jar as a resource to your JNLP file and you shouldn't have to sign it.
Please show your Manifest file.
The Manifest file should contain at least the following JavaFX entries:
JavaFX-Version: 2.2
JavaFX-Application-Class: yourPackage.YourApplication
Main-Class: com/javafx/main/Main
The JAR should contain the classes of the com.javafx.main package provided by the ant-javafx.jar (see /resources/classes in that Jar). The ant-javafx.jar is provided by the JDK.
I was able to mostly resolve my problem. I'm using Eclipse, not NetBeans, so doing a lot manually. The basic problem was that I had to include the jfxrt.jar as a resource in the jnlp file (and that jar also had to be signed).
My app now runs if I access the jnlp directly, though it still doesn't work via html page. I'll post an update if/when I figure that part out.

Configuring Netbeans with JNotify

I'm trying to use the JNotify library along with netbeans, however I don't know the proper way to configure it. Everything I try, the lines involving jnotify (eg. import net.contentobjects.jnotify.*) are underlined in red. Google seems to show nothing helpful regarding netbeans with jnotify, although I assume it's something simple like adding it to the classpath. I've tried adding the .jar as a library for compile & for run, no go.
The line i've been provided for running my app from the jnotify page:
-cp jnotify.jar -Djava.library.path=.
should I be using this as my compiling options or VM run options or both? seeing as I don't want to have to distribute my app with a .dll or .so file or the jnotify .jar.
Everyone on this site recommends using such and such a library, but they don't realize how hard they can be to set up (jnotify,boost,curl), and most who recommend them have probably never even used them themselves.
You're right, you have to add every library you use in your programs, into the projects classpath:
Click on the project node in your 'Projects' window. It should by default have a node called 'Libraries'.
Right click this node and select 'Add JAR/Folder'
Locate the JNotify.jar on the file dialog and press 'Open'.
Refresh your project, or just give netbeans some time to rescan the classpath, and you should be good to go.
There definately is something wrong with your classpath. While the above is exactly how you set the classpath when running a Java program, its different for a NetBeans project.
Follow these articles on how to add extenal jars to a NetBeans project.

Categories

Resources