Avvio rapido Java
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo progetto mostra come implementare una semplice
parte di Glassware che dimostra le principali funzionalità dell'API Google Mirror.
Per vedere una demo completa del progetto ad avvio rapido, vai a
https://glass-python-starter-demo.appspot.com.
In caso contrario, continua a leggere per scoprire come eseguire il deployment della tua versione.
Scarica su GitHub
Prerequisiti
Assicurati che il sistema soddisfi i seguenti prerequisiti per il progetto ad avvio rapido:
- Java 1.6
- Apache Maven: utilizzato per parte del processo di compilazione.
Creazione di un progetto nella console API di Google
Successivamente, abilita l'accesso all'API Google Mirror:
- Vai alla console API di Google e crea un nuovo progetto API.
- Fai clic su Servizi e abilita l'API Google Mirror per il tuo nuovo progetto.

- Fai clic su Accesso API e crea un ID client OAuth 2.0 per un'applicazione web.

- Specifica il nome e l'icona del prodotto Glassware. Questi campi vengono visualizzati nella concessione OAuth
ai tuoi utenti.

- Seleziona Web application (Applicazione web) e specifica un qualsiasi valore per il nome host, ad esempio
localhost

- Fai clic su Modifica impostazioni... per l'ID client in modo da specificare gli URI di reindirizzamento. Specifica gli URL di callback
per il server web di sviluppo locale, ad esempio
http://localhost:8080/oauth2callback
, e
per il server web di cui hai eseguito il deployment, ad esempio https://example.com/oauth2callback
.

- Prendi nota dell'ID client e del secret dalla console API di Google. Ti serviranno
per configurare il progetto di avvio rapido.

Configura il progetto Avvio rapido in modo che utilizzi le informazioni sul client API inserendo l'ID client e
secret in 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
Importazione del progetto
Le istruzioni riportate di seguito mostrano come importare l'origine del progetto di avvio rapido in IntelliJ e
Eclissi.
IntelliJ
- Fai clic su File > Importa progetto...
- Posiziona il puntatore del mouse sulla directory estratta.
- Seleziona Importa da un modello esistente > Maven
Eclipse
- Installa il plug-in
m2e
per abilitare l'importazione da un file Pom Maven.
- Fai clic su File > Importa... > Maven > Progetto Maven esistente.
- Posiziona il puntatore del mouse sulla directory estratta e importa il progetto.
Esecuzione di un server di sviluppo locale
Puoi eseguire il progetto Avvio rapido su un server di sviluppo locale per testare:
$ mvn jetty:run
Deployment del progetto Avvio rapido
Puoi creare un file di guerra per questo progetto utilizzando Maven:
$ mvn war:war
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-25 UTC.
[null,null,["Ultimo aggiornamento 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"]]