Ibrar
Ibrar

Reputation: 11

My javafx Code Obfuscated Successfully But now It is not running due to error in loading .fxml File from main method

I obfuscated my javafx code that contains .fxml files for view. After successful obfuscation when i run the jar file using command line, it shows the error in main method that the code is unable to load .fxml file.

Please help

Upvotes: 1

Views: 161

Answers (1)

user11321608
user11321608

Reputation:

This may not be what your looking for, but you could always use a FXML to java converter to create an abstract class.
Then you have the controller for the xml file extend the abstract class, you'll have to remove the initialize method (it's no longer necessary) and change the @FXML annotation for any methods that handle events to @Overrides.
Also you'll no longer need any of the fields with an @FXML annotation as all controls will be accessible through the abstract base class. If you use Netbeans there is a plugin to do this available through the plugin portal, or a stand alone jar file can be found here: https://www.tutorialon.com/p/fxmltojavaconverter.html

Then instead of loading fxml you just use the class constructor. For example if the root element in your FXML is a BorderPane, then you would use something like

BorderPane borderPane = new MyClass();

Upvotes: 0

Related Questions