
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a Compute Engine Virtual Machine Instance (zone: us-central1-f)
/ 5
Install software and configure the VM instance
/ 5
Run application software to get success response
/ 5
In this lab, you set up a Java development environment on Google Cloud. You use Google Compute Engine to create a virtual machine (VM) and install software libraries for software development.
You perform the following tasks:
Google Cloud consists of a set of physical assets, such as computers and hard disk drives, and virtual resources, such as virtual machines (VMs), that are contained in Google's data centers around the globe. Each data center location is in a global region. Regions include Central US, Western Europe, and East Asia. Each region is a collection of zones, which are isolated from each other within the region. Each zone is identified by a name that combines a letter identifier with the name of the region. For example, zone a in the East Asia region is named asia-east1-a.
This distribution of resources provides several benefits, including redundancy in case of failure and reduced latency by locating resources closer to clients. This distribution also introduces some rules about how resources can be used together.
Any Google Cloud resources that you allocate and use must belong to a project. You can think of a project as the organizing entity for what you're building.
A project is made up of the settings, permissions, and other metadata that describe your applications.
Resources within a single project can work together easily, for example by communicating through an internal network, subject to the regions-and-zones rules. The resources that each project contains remain separate across project boundaries; you can only interconnect them through an external network connection.
Each Google Cloud project has a:
As you work with Google Cloud, you'll use these identifiers in certain command lines and API calls.
The Google Cloud Console displays project name, ID and number under Home > Dashboard.
Each project ID is unique across Google Cloud. Once you have created a project, you can delete the project but its ID can never be used again.
When billing is enabled, each project is associated with one billing account. Multiple projects can have their resource usage billed to the same account.
A project serves as a namespace. This means every resource within each project must have a unique name, but you can usually reuse resource names if they are in separate projects. Some resource names must be globally unique. Refer to the documentation for the resource for details.
In this lab, you provision a Google Compute Engine virtual machine (VM) and install software libraries for Java software development on Google Cloud.
Google Cloud gives you three basic ways to interact with the services and resources:
Google Cloud Console: a web-based, graphical user interface that you can use to manage your Google Cloud projects and resources.
Command-line interface:
If you prefer to work in a terminal window, the Google Cloud SDK provides the gcloud command-line tool, which gives you access to the commands you need. The gcloud tool can be used to manage both your development workflow and your Google Cloud resources. See the gcloud reference for the complete list of available commands.
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
In this section, you use the Google Cloud Console to provision a new Google Compute Engine virtual machine (VM) instance.
Name: dev-instance
Region: us-central1
Zone: us-central1-f
Click Networking.
For Firewall, enable Allow HTTP traffic.
Click Security.
For Access scopes, enable Allow full access to all Cloud APIs.
Leave the remaining settings as their defaults, and click Create.
It takes about 20 seconds for the virtual machine to be provisioned and started.
On the VM instances page, in the row for the dev-instance, click SSH (in the Connect column).
This launches a browser-hosted SSH session. If you have a popup blocker, you may need to click twice. There's no need to configure or manage SSH keys.
Click Check my progress to verify your performed task. If you have completed the task successfully you will granted with an assessment score.
In the SSH session, to update the Debian package list, enter the following command:
Install Java 17:
Apply workaround for certificate issue in OpenJDK 17:
Install Git:
Install Maven:
Configure IP tables:
This command (above) to configure the IP tables redirects requests on Port 80 to Port 8080 - the Java Web application listens on Port 8080.
Export the Project ID as an environment variable:
Click Check my progress to verify your performed task. If you have completed the task successfully you will granted with an assessment score.
In this section, you verify the software installation and run some sample code.
To check the version of Java, enter the following command:
Example output:
You should see the JDK version 11.x.x, with the "11" representing the Java version number.
Clone the class repository:
To keep the navigation simple, create a soft link as a shortcut to the working directory:
Change to the directory that contains the sample files:
Run a simple web application:
Wait for the project to build. When the project successfully finishes you will see output similar to this:
Run the application:
You may see a number of warnings, but the project is running when you can see an INFO message in the output similar to the following:
Return to the Cloud Console VM instances list, and click on the External IP address for the dev-instance.
A browser opens to display a Hello GCP dev!
message from Java.
Click Check my progress to verify your performed task. If you have completed the task successfully you will granted with an assessment score.
Return to the SSH window, and stop the application by pressing Ctrl+C.
To run a simple Java application that lists Compute Engine instances, execute the following command:
The terminal window outputs VM details.
Below is a multiple-choice question to reinforce your understanding of this lab's concepts.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one