Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Linux 下 Google Docs List API Java 开发环境搭建指南 说明: 本文档说明了在 Linux 使用 Eclipse 搭建 Google Docs 开发环境流程,经过个人实践测试 通过,所有的软件版本以个人说明为主,其他版本请参考使用。本文档并非独创,大部分的 软件使用方法来自于网络。 所需软件资源列表 JDK 1.6 Eclipse 3.5 软件安装指南 下载 jdk-6u11-linux-i586-rpm.bin.gz,假设放到目录/opt 下,切换到 root 用户 执行下面的命令 gunzip jdk-6u11-linux-i586-rpm.bin.gz Chmod +x jdk-6u11-linux-i586-rpm.bin ./jdk-6u11-linux-i586-rpm.bin 阅读协议说明,最后键入 yes 进行安装即可。 安装完成之后需要设置环境变量,如下: #vi /etc/profile 在最后面加入 #set java environment JAVA_HOME=/usr/java/jdk-1_5_0_02 CLASSPATH=.:$JAVA_HOME/lib.tools.jar PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME CLASSPATH PATH 完成之后,回到当前使用用户 source 一下使之生效。 #source /etc/profile 至此为止,JDK 安装完成,验证一下,输入 java -version,出现如下信息: java version "1.6.0_0" OpenJDK Runtime Environment (IcedTea6 1.6) (fedora-30.b16.fc11-i386) OpenJDK Server VM (build 14.0-b16, mixed mode) 说明安装已经成功了! Eclipse 的下载以及安装 到官方网站下载 Eclipse 3.3,解压之后即可直接使用。为了方便,可以在桌面上建立一个快 捷方式,方法如下: 首先在桌面上点击右键,在跳出窗口中选择第三个选项「新增启动器(A) 」,之后会出现上 图 的画面。分别在 「名称」栏中输入 eclipse、 「指令」栏中输入/opt/eclipse/eclipse,然后按下「图标」栏右边的「没有图标」按钮。 这时候按下确定按钮桌面上就会出现的 eclipse 图标,以后就可以直接点选该图标来执行 eclipse。 Coding in the Shade: Using Eclipse with Google Data APIs Jeff Fisher, Google Data APIs Team April 2008 New Introduction Setting up Eclipse Installing required libraries Creating a new application Conclusion Google Data APIs Java Client Eclipse Plug-in : Create projects in seconds As a supplement to this article, an Eclipse plug-in is available to minimize the overhead involved in setting up the Google Data dependencies. It also creates boilerplate code to interact with the API that you are interested in. This provides an easy way to get started developing with the Google Data APIs. Instructional Video Download Installing the Plug-in Starting a new Google Data API Project Introduction Eclipse is a very handy (and free!) IDE that has a special place in the hearts of many Java programmers. It is not a surprise then, that you might want to use it with the Java client library to make a killer Java application that works with one of the Google Data APIs. Setting up Eclipse If you don't have Eclipse installed yet, you've been missing out. Eclipse can make Java development a lot easier, due to its ability to suggest fixes, find missing imports, and autocomplete methods. Go to the Eclipse.org downloads pageto get the installer for your operating system. To run Eclipse you'll have to have a JRE installed, which is linked to from the Eclipse downloads page. Once you've installed Eclipse, you'll need to create a workspace. These examples use /usr/local/eclipse/workspace. Installing required libraries Eclipse provides a lot of Java functionality out of the box, so this should be easy. First things first, grab the latest version of the Java client library from the project downloads page. Note that there are two separate downloads: one for samples, and one for the source code. Download the samples zip, since that includes the compiled JAR files of the Java client library needed to create your own programs. If you are curious about how the client library itself works, you can download the source zip and look through it, but that is outside the scope of this article. Once you've downloaded the samples zip, unzip the file to a convenient directory where you can find the files. The examples use /usr/local/eclipse. This means the JAR files for the project should now be accessible under /usr/local/eclipse/gdata/java/lib.x Now that you have installed the client library, the next thing to do is download some external dependencies so we can include them in the project build path. The INSTALL-samples.txtfile contains a list of jars you'll need and locations to download them from. The current list is: Filename mail.jar Location Sun's JavaMail API activation.jar Sun's JavaBeans Activation Framework servlet-api.jar Apache Tomcat In this example, these JAR files are downloaded and copied to /usr/local/eclipse/gdata/third_party. Whew! Now you should have all the pieces you need to start developing a Java application that uses one of the Google Data APIs. Read on! Creating a new application The first step is to open Eclipse and select "New > Java Project" from the File menu. Now click Next and select the Libraries tab. Add in all of the dependent JAR files you downloaded by clicking on Add External JARs. You also will have to add in the JAR files from the Java client library. They are located in the java/libsubdirectory of where you extracted the client library. You will alwayshave to include the following JAR files: gdata-client, gdata-client-meta, gdata-core, and gdata-media. Now choose which API you wish to use. This example uses the Google Documents List API. This requires adding in the appropriate JAR files: gdata-docs and gdata-docs-meta. Finally you can click "Finish" and create your new project. To make a simple test application, create a new class with a main method by selecting "New > Class" from the File menu. Now I'm going to paste in some code from the Developer's Guide for the Documents List API. You will see a lot of errors until you add the appropriate import statements. Eclipse makes this easy, all you have to do is click on the error markers on the left to get a helpful menu that lets you add imports. Once you have cleaned up the imports, you also have to handle exceptions that can be thrown by our code. The example opts to surround the entire sample code with a very rudimentary exception handler. Now, assuming that you substitute the username and password with a valid test account you have created, you should be able to see a list of documents owned by that test account when you choose "Run" from the Run menu. Hooray! Conclusion Now that you have a working instance of Eclipse and all the required JAR files in place, you are well on your way to building an awesome Java application that works with one of the Google Data APIs. Where to go from here? There are a few links you may find useful: Google Data APIs Java Client Eclipse Plug-in Google Data protocol documentation on code.google.com Google Data Java client library project Getting Started guide for the Java Client Library JavaDoc documentation Java is a trademark of Sun Microsystems, Inc. in the United States and other countries. 之后还要添加 collection-1.0.jar 才能避免出现第一个异常。 在 Eclipse 中设置使用代理的方法如下: window-->preferences-->general-->network connections 选中 manual proxy configuration: 填入 http proxy , port 代理需要用帐号和密码就需要选中 Enable proxy authentication,然后填上 user name 及 password Introduction This page demonstrates how to create a new Google Data template of your choice in a few steps using the Google Data plug-in. Steps to create a new Google Data Template For demonstration purpose, we will create a new Google Documents template which uses the Google Documents List Data API. Step 1:Go to File --> New --> Others Step 2:A new project wizard will open up. Scroll until you find a folder named 'Google Data'. Expand it and click on 'Google Data Project' and then click next. Step 3:A Google Data Project wizard page will open up which will ask for some information to create a new Google Data Project. Step 4:We will now enter appropriate information. o o Enter a valid project name. Say: My Document Project Select the 'Documents' template from the template list. You can see o o a corresponding description of the selected template next to the template list. Now, click on the 'Browse' button to select a directory containing the GData Java Client Lib files i.e. something like .../gdata/java/lib Now, since the description says that the 'Documents' template will require external dependencies, we need to select either the 'Download dependencies to' option or the 'Select Location' option. If you do not have the required dependencies on your system, you can select to download them. Step 5:After filling in the required information, click on 'Finish' button. Step 6:A new Java project is created in the workspace with the project name you provided. The Documents template named 'Documents.java' will be opened for editing. It will have instructions on how to execute it. All the required dependencies are referenced as 'Referenced Libraries'. If you are a new Eclipse user, click here to know how to set the execution arguments.