Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: com/google/gson/GsonBuilder error

I'm trying to make an irc bot in java that uses the Google api to search for things. I found a tutorial that uses GSON and the program compiles just fine. When I try to actually use the bot I get the error.

My import:

import com.google.gson.*; 

The line that is giving me the error

Gson gson=new GsonBuilder().create(); 

I am using this as a guide http://preciselyconcise.com/apis_and_installations/json_to_java.php

like image 524
Xun Avatar asked Feb 01 '26 17:02

Xun


1 Answers

You probably didn't do step 2 properly.

Include the gson library to your classpath.(Using an IDE you can add the gson.jar to your java project.)

If you are using an IDE, such as Eclipse and this project is a Java project (as opposed to a Maven project) then add the gson.jar to your lib folder.

like image 168
Alexandre Santos Avatar answered Feb 03 '26 09:02

Alexandre Santos