开发者

Package com.google does not exist

I'm using Netbeans IDE 7.0.1. I base my question on the CalculatorApp sample application available with the IDE. The sample is running 开发者_StackOverflow中文版fine but I wish I could use some JSON, ad so I download google-gson-stream-1.7.1.jar library, and included it in my libraries : - right click on "Library", then "Properties" then "Add JAR/Folder" and selected my JAR (located somewhere in "My Documents/Download".

The problem is that when i type the following :

import com.google.gson;

(or even com.google), the IDE fires a "Package com.google does not exist". The JAR and its hierarchy is correctly shown on the left side pane,in the "Libraries" section. Most surprising, the IDE can autocomplete the com.google.** stuff.

AFAIK, I need to further to get this work, don't I ? Any ideas ?

Thank you !


In Java, import statements are for classes and interfaces (types) not for packages themselves. Are you sure you tried to import a class under com.google.gson package and not the package itself?

import com.google.gson.Foo; should work.

So should

import com.google.gson.*; or import com.google.*;

Note however that wildcard imports aren't particularly recommended.


I am using:

import com.google.gson.Gson;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜