Receving error: package X does not exist

I'm trying to compile a small test program that uses the java api to interface with google docs.
Here's is the full error message:

GoogleDocsUpdate.java:2: package com.google.gdata.data does not exist
import com.google.gdata.data.*;

My classpath is set to include gdata-client-1.0.jar which contains the path
com/google/gdata/data/<bunch of *.class files>
opikeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Please post output of

jar tf gdata-client-1.0.jar
0
opikeAuthor Commented:
Here's the code I'm trying to compile.
import com.google.gdata.client.spreadsheet.*;
import com.google.gdata.data.*;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;


class GoogleDocsUpdate
{


public static void main (String[] args)
{
	//The service name info being passed is for google's tracking purposes
	SpreadsheetService myService = new SpreadsheetService("exampleCo-exampleApp-1");
	
	myService.setUserCredentials("********@gmail.com", "********");
	


}



}

Open in new window

0
opikeAuthor Commented:
Here's the output of jar tf gdata-client-1.0.jar

META-INF/
META-INF/MANIFEST.MF
com/
com/google/
com/google/gdata/
com/google/gdata/data/
com/google/gdata/data/extensions/
com/google/gdata/data/extensions/BaseEventEntry$EventStatus.class
com/google/gdata/data/extensions/BaseEventEntry$Transparency.class
com/google/gdata/data/extensions/BaseEventEntry$Visibility.class
com/google/gdata/data/extensions/BaseEventEntry.class
com/google/gdata/data/extensions/BaseEventFeed.class
com/google/gdata/data/extensions/Comments$Handler.class
com/google/gdata/data/extensions/Comments.class
com/google/gdata/data/extensions/ContactEntry.class
com/google/gdata/data/extensions/ContactFeed.class
com/google/gdata/data/extensions/Deleted.class
com/google/gdata/data/extensions/Email$Handler.class
com/google/gdata/data/extensions/Email$Rel.class
com/google/gdata/data/extensions/Email.class
com/google/gdata/data/extensions/EntryLink$Handler.class
com/google/gdata/data/extensions/EntryLink.class
com/google/gdata/data/extensions/EventEntry.class
com/google/gdata/data/extensions/EventFeed.class
com/google/gdata/data/extensions/ExtendedProperty$Handler.class
com/google/gdata/data/extensions/ExtendedProperty$Realm.class
com/google/gdata/data/extensions/ExtendedProperty.class
com/google/gdata/data/extensions/FeedLink$Handler.class
com/google/gdata/data/extensions/FeedLink.class
com/google/gdata/data/extensions/GeoPt$Handler.class
com/google/gdata/data/extensions/GeoPt.class
com/google/gdata/data/extensions/Im$Protocol.class
com/google/gdata/data/extensions/Im$Rel.class
com/google/gdata/data/extensions/Im.class
com/google/gdata/data/extensions/Image$Handler.class
com/google/gdata/data/extensions/Image$Rel.class
com/google/gdata/data/extensions/Image.class
com/google/gdata/data/extensions/Labels.class
com/google/gdata/data/extensions/MessageEntry.class
com/google/gdata/data/extensions/MessageFeed.class
com/google/gdata/data/extensions/Money.class
com/google/gdata/data/extensions/OrgDepartment.class
com/google/gdata/data/extensions/OrgJobDescription.class
com/google/gdata/data/extensions/OrgName.class
com/google/gdata/data/extensions/OrgSymbol.class
<rest truncated....>
0
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

CEHJCommented:
That jar is not in your classpath
0
CEHJCommented:
Please place the following as the first line in main and tell me what it prints
System.out.println(System.getProperty("java.class.path"));

Open in new window

0
VenabiliCommented:
actually it looks like there is nothing in com.google.gdata.data.* - just in the subpackages (unless if it is in the truncated part). |

Which class do you need from this package?
0
Mick BarryJava DeveloperCommented:
> import com.google.gdata.data.*;

remove that line
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
>>actually it looks like there is nothing in com.google.gdata.data.*

You're right!
0
VenabiliCommented:
:)

opike,

If you need just one class, just import the one class:
import com.google.gdata.client.spreadsheet.SpreadsheetService;

If you need a second one later - import it again. You do not win anything by importing full packages (well - it makes the code smaller but...) . Especially when you are using third-parrty libraries - because if in some of them there is a class named as a standard Java one, you might end up using this class instead of the one you think you are using... (such as javax.management.Query and com.google.gdata.client.Query for example - not that you are trying to use these but just an example).
0
Mick BarryJava DeveloperCommented:
you also need to add gdata-base-1.0.jar to your classpath
0
VenabiliCommented:
Only if he needs a class from there... :) The code he tries to compile above does not need it really.
0
opikeAuthor Commented:
SpreadSheetService.class is actually in the jar file gdata-spreadsheet-2.0.jar

I'm compiling with the following batch file:

set javahome=C:\progra~1\java\jdk1.6.0_18
set classpath=.;%javahome%;C:\dev\java\GoogleDocs\gdata-client-1.0.jar;C:\dev\java\GoogleDocs\gdata-spreadsheet-2.0.jar
set PATH=%PATH%;%javahome%\bin
javac -classpath "%classpath%" GoogleDocsUpdate.java

I changed the import statement to be:
import com.google.gdata.client.spreadsheet.SpreadSheetService;

So now the error is:
GoogleDocsUpdate.java:1: cannot find symbol
symbol  : class SpreadSheetService
location: package com.google.gdata.client.spreadsheet
import com.google.gdata.client.spreadsheet.SpreadSheetService;

gdata-spreadsheet-2.0.jar is in the correct directory:
C:\dev\java\GoogleDocs>dir
 Volume in drive C has no label.
 Volume Serial Number is D8E2-F857

 Directory of C:\dev\java\GoogleDocs

04/12/2010  07:47 PM    <DIR>          .
04/12/2010  07:47 PM    <DIR>          ..
04/12/2010  03:33 PM               248 compile.bat
04/12/2010  03:33 PM               202 compile.bat.bak
04/12/2010  12:08 PM            89,605 gdata-client-1.0.jar
04/12/2010  12:08 PM            89,605 gdata-client-1.0.zip
04/12/2010  12:08 PM            32,415 gdata-spreadsheet-2.0.jar
04/12/2010  12:08 PM            32,415 gdata-spreadsheet-2.0.zip
04/12/2010  12:05 PM         5,836,378 gdata-src.java-1.26.0.java.zip
04/12/2010  07:47 PM               504 GoogleDocsUpdate.java
04/12/2010  07:39 PM               510 GoogleDocsUpdate.java.bak
04/12/2010  04:29 PM             3,937 output.txt
04/12/2010  03:30 PM               227 run.bat
04/12/2010  03:28 PM               329 run.bat.bak
              12 File(s)      6,086,375 bytes
               2 Dir(s)  12,487,979,008 bytes free

0
Mick BarryJava DeveloperCommented:
> I changed the import statement to be:
> import com.google.gdata.client.spreadsheet.SpreadSheetService;

should be:

import com.google.gdata.client.spreadsheet.SpreadsheetService;

0
opikeAuthor Commented:
Oops - you're right. Fixed that but now still receiving the original error:

GoogleDocsUpdate.java:2: package com.google.gdata.data does not exist
import com.google.gdata.data.*;
0
Mick BarryJava DeveloperCommented:
See my earlier comment. you can remove that import
The spreadsheet import has nothing to do with your problem
0
opikeAuthor Commented:
You're right... and I also did need to add the gdata-core-1.0.jar to my classpath. It's now compiling. I'll split the points evenly.
0
Mick BarryJava DeveloperCommented:
glad I could help :)
0
Mick BarryJava DeveloperCommented:
for the benefit of others reading this question, you really should accept the comments that actually fixed your problem :)
0
Mick BarryJava DeveloperCommented:
For anyone reading this question the comment that actually fixed the problem was 30558314
0
opikeAuthor Commented:
Uh...if you really want to split hairs, in comment 30556298 Venabili was the first one to allude to the fact that the import com.google.gdata.data.* line could be removed.
0
Mick BarryJava DeveloperCommented:
that was fine, though the import wasn't the root of the problem, it was just unnecessary.
(and there *are* classes in that package)

Personally it doesn't bother me either way, just clarifying for others who have the same problem. Please don't take it personally, no malice intended :)

0
opikeAuthor Commented:
No worries..I appreciate your and everyone else's help.
0
VenabiliCommented:
>and there *are* classes in that package

Not in the jar that he had in his classpath - which for him meant that there is no classes in that package that he had imported and which is the cause of the problem.. And I did ask him why he needs this import in the same comment :) And for the code he posted above, he really did not need the aditional jars. But let's not get there, can we - the asker was helped, everyone here actually had their part in helping which is what we all are here for, right?

opike,

:) Good that you got it working.
0
Mick BarryJava DeveloperCommented:
>  And for the code he posted above, he really did not need the aditional jars.

He did,  as already explained. That was the problem.
Feel free to test it if you don't believe us.
0
Mick BarryJava DeveloperCommented:
> He did

sorry make that

(s)he did

:)
0
CEHJCommented:
>>Uh...if you really want to split hairs, in comment 30556298 Venabili was the first one to allude to the fact that the import com.google.gdata.data.* line could be removed.

Absolutely right

>>that was fine, though the import wasn't the root of the problem, it was just unnecessary.
(and there *are* classes in that package)

Wrong:
a. it *was* the root of the problem
b. there aren't any classes at that level, hence the error

For anyone reading the question later, the comment that correctly identified the problem was http:#30556298
0
Mick BarryJava DeveloperCommented:
does noone read comments anymore :)

> and I also did need to add the gdata-core-1.0.jar to my classpath.
0
VenabiliCommented:
For his full program most likely - not for the smallish one above.  He did not need the import for the few lines posted above.

Can we let this drop now?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.