Reputation: 691
I am working on a Maven- and 'NetBeans Platform'-based Java desktop application. My use case requires setting a system property as the very first step before anything else happens. I need to do this in the main
method, because using a static
block in the ModulInstall
is too late for my requirements. The challenge I'm facing is that I can't locate the main
method in my 'NetBeans Platform'-based Java desktop application.
Can someone guide me on where to find the main
method in a 'NetBeans Platform'-based application, or how I can write my own main
method for this type of application? I appreciate any insights or solutions to this issue.
Upvotes: 0
Views: 85
Reputation: 691
I successfully resolved my issue with the guidance provided in this post: https://stackoverflow.com/a/12908982/13583700
I utilized a custom main
method to set the system property as the initial step, ensuring it precedes any other actions. Afterward, I invoked NetBeans's main
method.
Upvotes: 0
Reputation: 6045
I once had a similar problem where the OnStart annotation (source / example) was executed too late.
Since I only had a single NetBeans module I introduced an abstract TopComponent class. Within the constructor I had a synchronized initialization block. Every other TopComponent extended from the abstract class. Since there is no order in which the modules are initialized, the first module that gets loaded initializes the code.
That worked pretty well for me even though I consider it quite hacky.
(At least) Two things you need to consider:
Upvotes: 0