To give a complete answer we actually need to know what's the name of the class that contains that main
method. Also, I'm struggling to understand such a weird requirement but I'll do my best to come up with a useful answer.
To invoke your main
method you need to access it through the class that contains it, since it's a static
method. You also need to provide an array of arguments mainly because it seems that your main method is using the first of the elements in the arguments array. So something like this would work:
private void CompareActionPerformed(java.awt.event.ActionEvent evt) {
String[] args = new String[] { "myparam" };
MainClass.main(args);
}
Now, said that, let me note that such an invocation of a main method is a very bad practice, you could achieve the same copying the contents of your main method into your event handler CompareActionPerformed
. Or even better, creating a separate and independent class with an static method that performs the same that you need from your main method. Then invoke that new static method from your main class and from your event handler (assuming that all the code is accessible from the same class loader).