i am trying to create a java application using firebase admin sdk this code is tested
FileInputStream serviceAccount =
new FileInputStream("path/to/serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder().setCredentials(GoogleCredentials.fromStream(serviceAccount)).build();
FirebaseApp.initializeApp(options);
and it works perfectly fine
the problem appears when the jar file is exported, when using this command java -jar fileName.jar
an exception appears:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/firebase/FirebaseOptions$Builder
at Launcher.initFirebase(Launcher.java:22)
at Launcher.main(Launcher.java:32)
Caused by: java.lang.ClassNotFoundException: com.google.firebase.FirebaseOptions$Builder
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
after searching for the problem, the issue was suggested to be exported jar doesn't include the library. so i forced the exported jar to contain the library like this
still the error is the same. any suggestions?