java开发桌面eclipse,在Java桌面应用程序中使用Firebase Admin(使用Eclipse)

I want to use firebase admin in my java application. On the website it says I can add it via gradle or maven. But I don't want to do that. Instead I downloaded the jar file from maven central repository website and added it as a library to my project. I added the code as stated on the firebase guides section and run the application and I get the following output;

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException

at error.myclass.main(myclass.java:17)

Caused by: java.lang.ClassNotFoundException: org.json.JSONException

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 1 more

So I tried adding libraries to fix the problem, and every time I run the application I just got another error. These are the libraries I have currently added:

com.google.guava_1.6.0.jar

firebase-admin-4.0.3.jar

google-api-client-1.4.1-beta.jar

google-api-client-gson-1.22.0.jar

google-api-java-client-ext.jar

google-http-client-1.16.0-rc.jar

java-json.jar

Now the only error I get is this:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.api.client.json.gson.GsonFactory.getDefaultInstance()Lcom/google/api/client/json/gson/GsonFactory;

at com.google.firebase.FirebaseOptions$Builder.setServiceAccount(FirebaseOptions.java:76)

at MyClass.cool.main(cool.java:18)

I have correctly added all of the libraries so I do not understand why this is not working. So my question is how do I successfully add firebase admin to a java project in eclipse without using gradle or maven.

解决方案

I ended up learning how to use Maven which is actually simple when you understand how to set up the project correctly and access the pom.xml file. When I exported the project (with the libraries) all of the necessary jars required was in a folder which I have linked on dropbox.

Names of Libraries:

commons-codec-1.3.jar

commons-logging-1.1.1.jar

firebase-admin-5.2.0.jar

google-api-client-1.22.0.jar

google-api-client-gson-1.22.0.jar

google-http-client-1.22.0.jar

google-http-client-gson-1.22.0.jar

google-http-client-jackson2-1.22.0.jar

google-oauth-client-1.22.0.jar

gson-2.1.jar

guava-20.0.jar

httpclient-4.0.1.jar

httpcore-4.0.1.jar

jackson-core-2.1.3.jar

json-20160810.jar

jsr305-1.3.9.jar

Note that the files linked are unlikely to be updated, so I would recommend using Maven which should download all of the correct libraries based on the version number in your pom.xml file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值