opike
asked on
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/<bun ch of *.class files>
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/<bun
ASKER
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", "********");
}
}
ASKER
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/exte nsions/
com/google/gdata/data/exte nsions/Bas eEventEntr y$EventSta tus.class
com/google/gdata/data/exte nsions/Bas eEventEntr y$Transpar ency.class
com/google/gdata/data/exte nsions/Bas eEventEntr y$Visibili ty.class
com/google/gdata/data/exte nsions/Bas eEventEntr y.class
com/google/gdata/data/exte nsions/Bas eEventFeed .class
com/google/gdata/data/exte nsions/Com ments$Hand ler.class
com/google/gdata/data/exte nsions/Com ments.clas s
com/google/gdata/data/exte nsions/Con tactEntry. class
com/google/gdata/data/exte nsions/Con tactFeed.c lass
com/google/gdata/data/exte nsions/Del eted.class
com/google/gdata/data/exte nsions/Ema il$Handler .class
com/google/gdata/data/exte nsions/Ema il$Rel.cla ss
com/google/gdata/data/exte nsions/Ema il.class
com/google/gdata/data/exte nsions/Ent ryLink$Han dler.class
com/google/gdata/data/exte nsions/Ent ryLink.cla ss
com/google/gdata/data/exte nsions/Eve ntEntry.cl ass
com/google/gdata/data/exte nsions/Eve ntFeed.cla ss
com/google/gdata/data/exte nsions/Ext endedPrope rty$Handle r.class
com/google/gdata/data/exte nsions/Ext endedPrope rty$Realm. class
com/google/gdata/data/exte nsions/Ext endedPrope rty.class
com/google/gdata/data/exte nsions/Fee dLink$Hand ler.class
com/google/gdata/data/exte nsions/Fee dLink.clas s
com/google/gdata/data/exte nsions/Geo Pt$Handler .class
com/google/gdata/data/exte nsions/Geo Pt.class
com/google/gdata/data/exte nsions/Im$ Protocol.c lass
com/google/gdata/data/exte nsions/Im$ Rel.class
com/google/gdata/data/exte nsions/Im. class
com/google/gdata/data/exte nsions/Ima ge$Handler .class
com/google/gdata/data/exte nsions/Ima ge$Rel.cla ss
com/google/gdata/data/exte nsions/Ima ge.class
com/google/gdata/data/exte nsions/Lab els.class
com/google/gdata/data/exte nsions/Mes sageEntry. class
com/google/gdata/data/exte nsions/Mes sageFeed.c lass
com/google/gdata/data/exte nsions/Mon ey.class
com/google/gdata/data/exte nsions/Org Department .class
com/google/gdata/data/exte nsions/Org JobDescrip tion.class
com/google/gdata/data/exte nsions/Org Name.class
com/google/gdata/data/exte nsions/Org Symbol.cla ss
<rest truncated....>
META-INF/
META-INF/MANIFEST.MF
com/
com/google/
com/google/gdata/
com/google/gdata/data/
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
com/google/gdata/data/exte
<rest truncated....>
That jar is not in your classpath
Please place the following as the first line in main and tell me what it prints
System.out.println(System.getProperty("java.class.path"));
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
opike,
If you need just one class, just import the one class:
import com.google.gdata.client.sp readsheet. Spreadshee tService;
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.Qu ery for example - not that you are trying to use these but just an example).
opike,
If you need just one class, just import the one class:
import com.google.gdata.client.sp
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.Qu
you also need to add gdata-base-1.0.jar to your classpath
Only if he needs a class from there... :) The code he tries to compile above does not need it really.
ASKER
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_1 8
set classpath=.;%javahome%;C:\ dev\java\G oogleDocs\ gdata-clie nt-1.0.jar ;C:\dev\ja va\GoogleD ocs\gdata- spreadshee t-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.sp readsheet. SpreadShee tService;
So now the error is:
GoogleDocsUpdate.java:1: cannot find symbol
symbol : class SpreadSheetService
location: package com.google.gdata.client.sp readsheet
import com.google.gdata.client.sp readsheet. SpreadShee tService;
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
I'm compiling with the following batch file:
set javahome=C:\progra~1\java\
set classpath=.;%javahome%;C:\
set PATH=%PATH%;%javahome%\bin
javac -classpath "%classpath%" GoogleDocsUpdate.java
I changed the import statement to be:
import com.google.gdata.client.sp
So now the error is:
GoogleDocsUpdate.java:1: cannot find symbol
symbol : class SpreadSheetService
location: package com.google.gdata.client.sp
import com.google.gdata.client.sp
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
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
> I changed the import statement to be:
> import com.google.gdata.client.sp readsheet. SpreadShee tService;
should be:
import com.google.gdata.client.sp readsheet. Spreadshee tService;
> import com.google.gdata.client.sp
should be:
import com.google.gdata.client.sp
ASKER
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.*;
GoogleDocsUpdate.java:2: package com.google.gdata.data does not exist
import com.google.gdata.data.*;
See my earlier comment. you can remove that import
The spreadsheet import has nothing to do with your problem
The spreadsheet import has nothing to do with your problem
ASKER
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.
glad I could help :)
for the benefit of others reading this question, you really should accept the comments that actually fixed your problem :)
For anyone reading this question the comment that actually fixed the problem was 30558314
ASKER
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.
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 :)
(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 :)
ASKER
No worries..I appreciate your and everyone else's help.
>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.
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.
> 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.
He did, as already explained. That was the problem.
Feel free to test it if you don't believe us.
> He did
sorry make that
(s)he did
:)
sorry make that
(s)he did
:)
>>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
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
does noone read comments anymore :)
> and I also did need to add the gdata-core-1.0.jar to my classpath.
> and I also did need to add the gdata-core-1.0.jar to my classpath.
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?
Can we let this drop now?
jar tf gdata-client-1.0.jar