התחלה מהירה ב-Java
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בפרויקט הזה תראו איך להטמיע מודל
חלק מ-Glassware שמדגים את הפונקציונליות העיקרית של Google Mirror API.
כדי לראות הדגמה תקינה של הפרויקט להתחלה מהירה, צריך לעבור אל
https://glass-python-starter-demo.appspot.com.
אם לא, כדאי להמשיך לקרוא כדי ללמוד איך לפרוס גרסה משלכם.
הורדה מ-GitHub
דרישות מוקדמות
צריך לוודא שהמערכת עומדת בדרישות המוקדמות הבאות של הפרויקט להתחלה מהירה:
יצירת פרויקט במסוף Google APIs
לאחר מכן, מאפשרים גישה ל-Google Mirror API:
- נכנסים אל מסוף Google APIs ויוצרים פרויקט API חדש.
- לוחצים על שירותים ומפעילים את Google Mirror API בפרויקט החדש.

- לוחצים על API Access (גישה ל-API) ויוצרים מזהה לקוח ב-OAuth 2.0 לאפליקציית אינטרנט.

- יש לציין את השם והסמל של המוצר Glassware. השדות האלה מופיעים בבקשת ה-OAuth
של המסך שמוצג למשתמשים.

- בוחרים באפשרות Web application ומציינים ערך כלשהו עבור שם המארח, למשל
localhost
.

- כדי לציין מזהי URI להפניה אוטומטית, לוחצים על עריכת הגדרות... עבור מזהה הלקוח. ציון כתובות ה-URL לקריאה חוזרת (callback)
לשרת האינטרנט לפיתוח המקומי שלך, לדוגמה
http://localhost:8080/oauth2callback
,
עבור שרת האינטרנט שנפרס, לדוגמה https://example.com/oauth2callback
.

- מומלץ לרשום את מזהה הלקוח ואת הסוד ב-Google APIs Console. יש צורך
כדי להגדיר את הפרויקט להתחלה מהירה.

מגדירים לפרויקט 'התחלה מהירה' את השימוש בפרטי לקוח ה-API באמצעות הזנת מזהה הלקוח
סוד ב-src/main/resources/oauth.properties
:
# Replace these with values for your project from the Google API Console:
# https://developers.google.com/console
client_id=3141592653589793238462643383279
client_secret=ITS_A_SECRET_TO_EVERYBODY
ייבוא הפרויקט
בהוראות הבאות מוסבר לייבא את מקור הפרויקט 'התחלה מהירה' אל IntelliJ
ליקוי חמה.
IntelliJ
- לוחצים על קובץ > ייבוא פרויקט...
- מצביעים על הספרייה שחולץ.
- בוחרים באפשרות ייבוא ממודל קיים > Maven
אקליפס
- כדאי להתקין את הפלאגין
m2e
כדי להפעיל ייבוא מקובץ maven pom.
- לוחצים על קובץ > ייבוא... > Maven > פרויקט Maven קיים.
- מצביעים על הספרייה שחולצה ומייבאים את הפרויקט.
הפעלת שרת פיתוח מקומי
אפשר להריץ את הפרויקט 'התחלה מהירה' בשרת פיתוח מקומי כדי לבצע בדיקות:
$ mvn jetty:run
פריסת הפרויקט להתחלה מהירה
אפשר ליצור קובץ מלחמה לפרויקט הזה באמצעות Maven:
$ mvn war:war
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-25 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-25 (שעון UTC)."],[[["\u003cp\u003eThis project provides a simple implementation of Glassware demonstrating core Google Mirror API functionality.\u003c/p\u003e\n"],["\u003cp\u003eIt requires Java 1.6, Apache Maven, and a Google APIs Console project with the Google Mirror API enabled and OAuth 2.0 client ID created.\u003c/p\u003e\n"],["\u003cp\u003eThe project can be configured using your API client information, imported into IntelliJ or Eclipse, and run on a local development server using Maven.\u003c/p\u003e\n"],["\u003cp\u003eA deployable WAR file can be built using Maven for production deployment.\u003c/p\u003e\n"],["\u003cp\u003eA fully-working demo is available at \u003ca href=\"https://glass-java-starter-demo.appspot.com\"\u003ehttps://glass-java-starter-demo.appspot.com\u003c/a\u003e.\u003c/p\u003e\n"]]],[],null,["# Java Quick Start\n\nThis project shows you how to implement a simple\npiece of Glassware that demos the major functionality of the Google Mirror API.\n\nTo see a fully-working demo of the quick start project, go to\n[https://glass-python-starter-demo.appspot.com](https://glass-java-starter-demo.appspot.com).\nOtherwise, read on to see how to deploy your own version.\n\n[Download on GitHub](https://github.com/googleglass/mirror-quickstart-java)\n\nPrerequisites\n-------------\n\nEnsure your system meets the following prerequisites for the quick start project:\n\n- Java 1.6\n- [Apache Maven](http://maven.apache.org/) - used for part of the build process.\n\nCreating a Google APIs Console project\n--------------------------------------\n\nNext, enable access to the Google Mirror API:\n\n1. Go to the [Google APIs console](https://code.google.com/apis/console/) and create a new API project.\n2. Click **Services** and enable the Google Mirror API for your new project.\n3. Click **API Access** and create an OAuth 2.0 client ID for a web application.\n4. Specify the product name and icon for your Glassware. These fields appear on the OAuth grant screen presented to your users.\n5. Select **Web application** and specify any value for the hostname, such as `localhost`\n6. Click **Edit settings...** for the client ID to specify redirect URIs. Specify the callback URLs for your local development web server, for example `http://localhost:8080/oauth2callback`, and for your deployed web server, for example `https://example.com/oauth2callback`.\n7. Make note of the client ID and secret from the Google APIs Console. You'll need it to configure the quick start project.\n\nConfiguring the Quick Start project\n-----------------------------------\n\nConfigure the Quick Start project to use your API client information by entering your client ID and\nsecret into `src/main/resources/oauth.properties`: \n\n # Replace these with values for your project from the Google API Console:\n # https://developers.google.com/console\n\n client_id=3141592653589793238462643383279\n client_secret=ITS_A_SECRET_TO_EVERYBODY\n\nImporting the project\n---------------------\n\nThe following instructions show you to import the Quick Start project source into IntelliJ and\nEclipse.\n\n### IntelliJ\n\n1. Click **File \\\u003e Import Project...**.\n2. Point to the extracted directory.\n3. Select **Import from existing model \\\u003e Maven**\n\n### Eclipse\n\n1. Install the [`m2e`](http://eclipse.org/m2e/) plugin to enable import from a maven pom file.\n2. Click **File \\\u003e Import... \\\u003e Maven \\\u003e Existing Maven Project**.\n3. Point to the extracted directory and import the project.\n\nRunning a local development server\n----------------------------------\n\nYou can run the Quick Start project on a local development server for testing: \n\n $ mvn jetty:run\n\nDeploying the Quick Start project\n---------------------------------\n\nYou can build a war file for this project using Maven: \n\n $ mvn war:war"]]