0

I'm trying to turn an intellij project into a executable so I can run it outside of the intellij environment.

This project works perfectly inside the environment but when i turn it into a jar file the jar file has atleast one run time error.

The error I get first is:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
    at com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:314)
    at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:260)
    at com.google.firebase.database.FirebaseDatabase.getInstance(FirebaseDatabase.java:80)
    at com.google.firebase.quickstart.Database.main(Database.java:90)

This seems like something to do with not being connected to the Firebase libraries/frameworks I was connected to. However this is where I don't have much knowledge. I built the Jar file using project settings and then building an aritfact and that seemed fine but obviously some connection has been lost along the way. I'm wondering if anyone has similar issues or knows what to try?

Thanks

Lewis Black
  • 957
  • 2
  • 8
  • 22
  • Just to try to understand the problem, what you did was (1) created a jar file from within IntelliJ (2) executed "java -jar helloworld.jar" from command line (win or *nix?) and received the above error? – hammerfest Jun 26 '17 at 14:41
  • Yes, I'm using the windows command line. The exact command I put in was: java -cp quickstart-java-master.jar com.google.firebase.quickstart.Database . This worked as the first part of my program ran but it stopped and gave me an error on the call FirebaseDatabase.getInstance() – Lewis Black Jun 26 '17 at 14:43
  • I see. Can you view the contents of quickstart-java-master.jar and check whether the firebase jar(s) is/are packed within? You should be able to do that with "jar -tf quickstart-java-master.jar", or e.g. rename the jar to zip and open it with WinZip or other tool. – hammerfest Jun 26 '17 at 14:50
  • Ah have done, I have the firebase admin jar and a significant number of google jars (such as google-cloud-storage-1.0.1.jar and similar) but no jar for the firebase database (if there is one). In the code that does get executed when I do this one of the things that gets called seemingly successfully is FirebaseApp.initialise app, also I am using firebase database and google cloud storage linked to firebase storage. Not sure if they help – Lewis Black Jun 26 '17 at 14:59
  • OK, thank you. The problem actually seems to occur when the firebase code tries to call the checkState() method in com.google.common.base.Preconditions class, which is a class in the guava framework. Do you also have guava packed within quickstart-java-master.jar, and if yes with what version? – hammerfest Jun 26 '17 at 15:05
  • Btw, is this the project you are trying to use: https://github.com/firebase/quickstart-java? – hammerfest Jun 26 '17 at 15:08
  • Yeah, that's basically my project haha. I downloaded that to start with and haven't renamed it. Ah I've only heard of guava because of what i've been reading about online. I'm not sure if i've got it, I will only have got it if it was in the project I downloaded. How do I check for it? – Lewis Black Jun 26 '17 at 15:12
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/147628/discussion-between-lewis-black-and-hammerfest). – Lewis Black Jun 26 '17 at 15:13
  • Ok I see. This seems to be a project built with the gradle tool, which should ensure to retrieve all project dependency jars (like e.g. firebase, guava etc.) from remote repositories and execute the application. According to your above description you tried to create the application jar through IntelliJ and then execute it with the jar tool, which might not necessarily work. I suggest you to read https://github.com/firebase/quickstart-java/blob/master/database/README.md and use gradle from command line as described in there. – hammerfest Jun 26 '17 at 15:20
  • See http://stackoverflow.com/a/42200519/104891. – CrazyCoder Jun 26 '17 at 16:10

0 Answers0