I made a simple JavaFX program and I cannot seem to be able to obfuscate it with ProGuard.
I have followed this question: Obfuscating JavaFX application
This is my code:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class HelloWorld extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
AnchorPane root = new AnchorPane();
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
}
According to the answer in that question, this should be my configuration file:
-injars /Users/me/Desktop/MyProgram.jar
-outjars /Users/me/Desktop/Obfuscated.jar
-libraryjars <java.home>/lib/rt.jar
-libraryjars <java.home>/lib/ext/jfxrt.jar
-dontshrink
-dontoptimize
-flattenpackagehierarchy ''
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
-adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF
-keepclassmembernames class * {
@javafx.fxml.FXML *;
}
# Keep - Applications. Keep all application classes, along with their 'main'
# methods.
-keepclasseswithmembers public class com.javafx.main.Main, HelloWorld {
public static void main(java.lang.String[]);
}
But I get the following error when trying to run the .JAR program:
Error: Main method not found in class a.B, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
According to this other question: Error: Main method not found in class Calculate, please define the main method as: public static void main(String[] args)
I need my class to have a main
method with a body. Clearly I already got that, as you can see from my code above.
So what did I do wrong? I am using Java 8.