4

我在编译时遇到了一些错误。
我的目录结构是

main_directory/src/MyClass.java
main_directory/lib/{some external jars}

我的编译脚本

#!/bin/csh -b
setenv LIB_DIR $PWD/lib/
set CLASSPATH="${LIB_DIR}commons-logging-1.1.1.jar:${LIB_DIR}google-api-client-1.12.0-beta.jar:${LIB_DIR}google-api-client-android-1.12.0-beta.jar:${LIB_DIR}google-api-client-appengine-1.12.0-beta.jar:${LIB_DIR}google-api-client-java6-1.12.0-beta.jar:${LIB_DIR}google-api-services-analytics-v3-rev21-1.12.0-beta.jar:${LIB_DIR}google-http-client-1.12.0-beta.jar:${LIB_DIR}google-http-client-android-1.12.0-beta.jar:${LIB_DIR}google-http-client-appengine-1.12.0-beta.jar:${LIB_DIR}google-http-client-gson-1.12.0-beta.jar:${LIB_DIR}google-http-client-jackson-1.12.0-beta.jar:${LIB_DIR}google-http-client-jackson2-1.12.0-beta.jar:${LIB_DIR}google-oauth-client-1.12.0-beta.jar:${LIB_DIR}google-oauth-client-appengine-1.12.0-beta.jar:${LIB_DIR}google-oauth-client-java6-1.12.0-beta.jar:${LIB_DIR}google-oauth-client-jetty-1.12.0-beta.jar:${LIB_DIR}google-oauth-client-servlet-1.12.0-beta.jar:${LIB_DIR}gson-2.1.jar:${LIB_DIR}guava-jdk5-13.0.jar:${LIB_DIR}httpclient-4.0.3.jar:${LIB_DIR}httpcore-4.0.1.jar:${LIB_DIR}jackson-core-2.0.5.jar:${LIB_DIR}jackson-core-asl-1.9.9.jar:${LIB_DIR}jdo2-api-2.3-eb.jar:${LIB_DIR}jetty-6.1.26.jar:${LIB_DIR}jetty-util-6.1.26.jar:${LIB_DIR}jsr305-1.3.9.jar:${LIB_DIR}transaction-api-1.1.jar:${LIB_DIR}xpp3-1.1.4c.jar:${LIB_DIR}"

javac -d bin -sourcepath src -cp $CLASSPATH src/*.java

这里也是我的来源的一部分:

import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.analytics.Analytics;
import com.google.api.services.analytics.AnalyticsScopes;
import com.google.api.services.analytics.model.GaData;
import com.google.api.services.analytics.model.GaData.ColumnHeaders;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;

public class MyClass{

  /** E-mail address of the service account. */
  private static final String SERVICE_ACCOUNT_EMAIL = "something@something.com";
  /** Global instance of the HTTP transport. */
  private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();

 /** Global instance of the JSON factory. */
 private static final JsonFactory JSON_FACTORY = new JacksonFactory();

  private static final String TABLE_ID = "gt:93359";


    //private static Plus plus;

  public static void main(String[] args) {
    try {
      try {
        // check for valid setup
        if (SERVICE_ACCOUNT_EMAIL.startsWith("Enter ")) {
          System.err.println(SERVICE_ACCOUNT_EMAIL);
          System.exit(1);
        }

 ...

我在 main_directory 中运行我的编译脚本。并得到这些错误:

 error: error reading /tank/fmeng/myfolder/googleanaly/lib/commons-logging-1.1.1.jar; error in opening zip file
 src/PlusServiceAccountSample.java:17: package com.google.api.client.auth.oauth2 does     not exist
 import com.google.api.client.auth.oauth2.Credential;
                                     ^
 src/PlusServiceAccountSample.java:18: package     com.google.api.client.googleapis.auth.oauth2 does not exist
 import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
                                                ^
 src/PlusServiceAccountSample.java:19: package com.google.api.client.http does not exist
 import com.google.api.client.http.HttpTransport;
                              ^
 src/PlusServiceAccountSample.java:20: package com.google.api.client.http.javanet does not exist
 import com.google.api.client.http.javanet.NetHttpTransport;
                                      ^
 src/PlusServiceAccountSample.java:21: package com.google.api.client.json does not exist
 import com.google.api.client.json.JsonFactory;
                              ^
 src/PlusServiceAccountSample.java:22: package com.google.api.client.json.jackson2 does not exist
     import com.google.api.client.json.jackson2.JacksonFactory;
                                           ^
      src/PlusServiceAccountSample.java:23: package com.google.api.services.analytics does not exist
      import com.google.api.services.analytics.Analytics;
                                         ^
     src/PlusServiceAccountSample.java:24: package com.google.api.services.analytics does not exist
     import com.google.api.services.analytics.AnalyticsScopes;
                                         ^
      src/PlusServiceAccountSample.java:25: package com.google.api.services.analytics.model does not exist
      import com.google.api.services.analytics.model.GaData;
                                               ^
      src/PlusServiceAccountSample.java:26: package com.google.api.services.analytics.model.GaData does not exist
      import com.google.api.services.analytics.model.GaData.ColumnHeaders;
                                                      ^
      src/PlusServiceAccountSample.java:27: package com.google.common.io does not exist
      import com.google.common.io.Files;
                            ^
      src/PlusServiceAccountSample.java:42: cannot find symbol
      symbol  : class HttpTransport
      location: class PlusServiceAccountSample
      private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
                       ^
      src/PlusServiceAccountSample.java:45: cannot find symbol
     symbol  : class JsonFactory
     location: class PlusServiceAccountSample
      private static final JsonFactory JSON_FACTORY = new JacksonFactory();
                       ^
     src/PlusServiceAccountSample.java:118: cannot find symbol
         symbol  : class Analytics
         location: class PlusServiceAccountSample
          private static GaData executeDataQuery(Analytics analytics, String tableId) throws      IOException {
                                              ^
         src/PlusServiceAccountSample.java:118: cannot find symbol
    symbol  : class GaData
    location: class PlusServiceAccountSample
       private static GaData executeDataQuery(Analytics analytics, String tableId) throws IOException {
                  ^
src/PlusServiceAccountSample.java:131: cannot find symbol
symbol  : class GaData
location: class PlusServiceAccountSample
   private static void printGaData(GaData results) {
                                   ^
src/PlusServiceAccountSample.java:42: cannot find symbol
symbol  : class NetHttpTransport
location: class PlusServiceAccountSample
  private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
                                                          ^
src/PlusServiceAccountSample.java:45: cannot find symbol
symbol  : class JacksonFactory
location: class PlusServiceAccountSample
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();
                                                      ^
src/PlusServiceAccountSample.java:60: cannot find symbol
symbol  : variable Files
location: class PlusServiceAccountSample
        String p12Content = Files.readFirstLine(new File("key.p12"), Charset.defaultCharset());
                            ^
src/PlusServiceAccountSample.java:71: cannot find symbol
symbol  : class GoogleCredential
location: class PlusServiceAccountSample
        GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
        ^
src/PlusServiceAccountSample.java:74: cannot find symbol
symbol  : variable AnalyticsScopes
location: class PlusServiceAccountSample
            .setServiceAccountScopes(AnalyticsScopes.ANALYTICS)
                                     ^
src/PlusServiceAccountSample.java:71: package GoogleCredential does not exist
        GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
                                                          ^
src/PlusServiceAccountSample.java:84: cannot find symbol
symbol  : class Analytics
location: class PlusServiceAccountSample
            Analytics analytics = new Analytics.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
            ^
src/PlusServiceAccountSample.java:84: package Analytics does not exist
            Analytics analytics = new Analytics.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                                               ^
src/PlusServiceAccountSample.java:89: cannot find symbol
symbol  : class GaData
location: class PlusServiceAccountSample
            GaData gaData = executeDataQuery(analytics, TABLE_ID);
            ^
src/PlusServiceAccountSample.java:140: cannot find symbol
symbol  : class ColumnHeaders
location: class PlusServiceAccountSample
      for (ColumnHeaders header : results.getColumnHeaders()) {
           ^
27 errors

一些帮助将不胜感激。谢谢!

类路径回显:

/tank/fmeng/myfolder/googleanaly/lib/commons-logging-1.1.1.jar:/tank/fmeng/myfolder/googleanaly/lib/google-api-client-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-api-client-android-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-api-client-appengine-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-api-client-java6-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-api-services-analytics-v3-rev21-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-http-client-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-http-client-android-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-http-client-appengine-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-http-client-gson-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-http-client-jackson-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-http-client-jackson2-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-oauth-client-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-oauth-client-appengine-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-oauth-client-java6-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-oauth-client-jetty-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/google-oauth-client-servlet-1.12.0-beta.jar:/tank/fmeng/myfolder/googleanaly/lib/gson-2.1.jar:/tank/fmeng/myfolder/googleanaly/lib/guava-jdk5-13.0.jar:/tank/fmeng/myfolder/googleanaly/lib/httpclient-4.0.3.jar:/tank/fmeng/myfolder/googleanaly/lib/httpcore-4.0.1.jar:/tank/fmeng/myfolder/googleanaly/lib/jackson-core-2.0.5.jar:/tank/fmeng/myfolder/googleanaly/lib/jackson-core-asl-1.9.9.jar:/tank/fmeng/myfolder/googleanaly/lib/jdo2-api-2.3-eb.jar:/tank/fmeng/myfolder/googleanaly/lib/jetty-6.1.26.jar:/tank/fmeng/myfolder/googleanaly/lib/jetty-util-6.1.26.jar:/tank/fmeng/myfolder/googleanaly/lib/jsr305-1.3.9.jar:/tank/fmeng/myfolder/googleanaly/lib/transaction-api-1.1.jar:/tank/fmeng/myfolder/googleanaly/lib/xpp3-1.1.4c.jar:/tank/fmeng/myfolder/googleanaly/lib/
4

0 回答 0