I downloaded the Google JSON module a.k.a GSON. I'm ona windows system Could you tell me how to install the GSON module? I extracted the JAR into the following folder which was in my classpath:
C:\Program Files\Java\jdk1.6.0_07\lib
..but when i type:
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
I still get a module not found error.
What am I doing wrong?
Thanks.
Gson is the main actor class of Google Gson library. It provides functionalities to convert Java objects to matching JSON constructs and vice versa. Gson is first constructed using GsonBuilder and then toJson(Object) or fromJson(String, Class) methods are used to read/write JSON constructs.
JDK/lib
.You need to specify it in the classpath using -cp
or -classpath
argument. E.g.
java -cp .;/path/to/gson.jar com.example.MyClass
To save the time in typing it everytime, use a .bat
file to execute it.
If you're actually using an IDE like Eclipse, then you can also just rightclick the Java project, choose Build Path and then add it as new Library. Eclipse will then automatically take it in both the compiletime and runtime classpath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With