How to install the gson module in Java?

I downloaded the Google JSON module a.k.a gson I am a Windows system. Can you tell me how to install the gson module? I unzip the jar into the following folder in my classpath:

C:\Program Files\Java\jdk1.6.0_07\lib

But when I enter:

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

I still got a module and couldn't find the error

What on earth did I do wrong?

thank you.

Solution

>You shouldn't extract jars

You need to specify it in the classpath using the - CP or - classpath parameter For example

java -cp .;/path/to/gson.jar com.example.MyClass

To save time per input, use Bat file executes it

If you actually use an IDE like eclipse, you can also right-click the Java project, select build path, and add it as a new library Eclipse will then automatically run it in both compiletime and runtime classpath

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>