{"id":18429046,"url":"https://github.com/openliberty/guide-getting-started","last_synced_at":"2025-04-07T06:09:45.424Z","repository":{"id":32547744,"uuid":"131283092","full_name":"OpenLiberty/guide-getting-started","owner":"OpenLiberty","description":"An introductory guide to writing and deploying applications on Open Liberty using Maven and Docker: https://openliberty.io/guides/getting-started.html","archived":false,"fork":false,"pushed_at":"2025-03-17T21:44:23.000Z","size":1038,"stargazers_count":16,"open_issues_count":6,"forks_count":58,"subscribers_count":5,"default_branch":"prod","last_synced_at":"2025-03-31T05:03:38.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenLiberty.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-27T10:38:07.000Z","updated_at":"2025-03-29T19:15:17.000Z","dependencies_parsed_at":"2023-10-14T18:58:36.794Z","dependency_job_id":"cf0897f9-f56f-49cf-93eb-5d913513d9f3","html_url":"https://github.com/OpenLiberty/guide-getting-started","commit_stats":{"total_commits":349,"total_committers":47,"mean_commits":7.425531914893617,"dds":0.6045845272206304,"last_synced_commit":"354f5415531a9ad2cf567af046b4a1da0a6940ed"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenLiberty%2Fguide-getting-started","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenLiberty%2Fguide-getting-started/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenLiberty%2Fguide-getting-started/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenLiberty%2Fguide-getting-started/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenLiberty","download_url":"https://codeload.github.com/OpenLiberty/guide-getting-started/tar.gz/refs/heads/prod","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T05:15:36.743Z","updated_at":"2025-04-07T06:09:45.396Z","avatar_url":"https://github.com/OpenLiberty.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"// Copyright (c) 2018, 2025 IBM Corporation and others.\n// Licensed under Creative Commons Attribution-NoDerivatives\n// 4.0 International (CC BY-ND 4.0)\n//   https://creativecommons.org/licenses/by-nd/4.0/\n//\n// Contributors:\n//     IBM Corporation\n//\n:projectid: getting-started\n:page-layout: guide-multipane\n:page-duration: 25 minutes\n:page-releasedate: 2018-06-29\n:page-guide-category: basic\n:page-essential: true\n:page-essential-order: 1\n:page-description: Learn how to develop a Java application on Open Liberty with Maven and Docker.\n:page-tags: ['docker', 'maven']\n:page-related-guides: ['maven-intro', 'rest-intro', 'docker']\n:page-permalink: /guides/{projectid}\n:common-includes: https://raw.githubusercontent.com/OpenLiberty/guides-common/prod\n:source-highlighter: prettify\n:page-seo-title: Getting started with Open Liberty\n:page-seo-description: A getting started tutorial with examples on how to rapidly develop, build, and package a Java application on Open Liberty using Maven and Docker.\n:guide-author: Open Liberty\n= Getting started with Open Liberty\n\n[.hidden]\nNOTE: This repository contains the guide documentation source. To view the guide in published form, view it on the https://openliberty.io/guides/{projectid}.html[Open Liberty website].\n\nLearn how to develop a Java application on Open Liberty with Maven and Docker.\n\n== What you'll learn\n\nYou will learn how to run and update a simple REST microservice on Open Liberty. You will use Maven throughout the guide to build and deploy the microservice as well as to interact with the running Liberty instance.\n\nOpen Liberty is an open application framework designed for the cloud. It's small, lightweight, and designed with modern cloud-native application development in mind. It supports the full MicroProfile and Jakarta EE APIs and is composable, meaning that you can use only the features that you need, keeping everything lightweight, which is great for microservices. It also deploys to every major cloud platform, including Docker, Kubernetes, and Cloud Foundry.\n\nMaven is an automation build tool that provides an efficient way to develop Java applications. Using Maven, you will build a simple microservice, called `system`, that collects basic system properties from your laptop and displays them on an endpoint that you can access in your web browser. \n\nYou'll also explore how to package your application with Open Liberty so that it can be deployed anywhere in one go. You will then make Liberty configuration and code changes and see how they are immediately picked up by a running instance.\n\nFinally, you will package the application along with Liberty's configuration into a Docker image and run that image as a container.\n\n\n// =================================================================================================\n// Getting Started\n// =================================================================================================\n\n[role='command']\ninclude::{common-includes}/gitclone.adoc[]\n\nYou have cloned a Maven project. To learn how to create a Liberty Maven project from scratch and edit your application using the Liberty Tools, see https://openliberty.io/blog/2024/05/31/liberty-project-starter-guide-IntelliJ.html[Developing a cloud-native Java application with Liberty Tools in IntelliJ IDEA^].\n\n// Cloud hosted guide instruction\nifdef::cloud-hosted[]\nIn this IBM Cloud environment, you need to change the user home to ***/home/project*** by running the following command:\n```bash\nsudo usermod -d /home/project theia\n```\nendif::[]\n\n\n// =================================================================================================\n// Building and running the application\n// =================================================================================================\n\n== Building and running the application\n\nYour application is configured to be built with Maven. Every Maven-configured project contains a [hotspot]`pom.xml` file, which defines the project configuration, dependencies, plug-ins, and so on.\n\nYour [hotspot]`pom.xml` file is located in the `start` directory and is configured to include the [hotspot=libertyMavenPlugin]`liberty-maven-plugin`, which allows you to install applications into Open Liberty and manage the associated Liberty instances.\n\npom.xml\n[source, XML, linenums, role=\"code_column\"]\n----\ninclude::finish/pom.xml[]\n----\n\nTo begin, navigate to the `start` directory. Build the `system` microservice that is provided and deploy it to Open Liberty by running the Maven `liberty:run` goal:\n\n[role='command']\n```\ncd start\nmvn liberty:run\n```\n\nThe `mvn` command initiates a Maven build, during which the `target` directory is created to store all build-related files.\n\nThe `liberty:run` argument specifies the Open Liberty `run` goal, which starts an Open Liberty instance in the foreground. As part of this phase, an Open Liberty runtime is downloaded and installed into the `target/liberty/wlp` directory, an instance of Liberty is created and configured in the `target/liberty/wlp/usr/servers/defaultServer` directory, and the application is installed into that instance using https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/rwlp_loose_applications.html[loose config^].\n\nFor more information about the Liberty Maven plug-in, see its https://github.com/WASdev/ci.maven[GitHub repository^].\n\nWhen the Liberty instance begins starting up, various messages display in your command-line session. Wait for the following message, which indicates that Liberty's startup is complete:\n\n[source, role=\"no_copy\"]\n----\n[INFO] [AUDIT] CWWKF0011I: The server defaultServer is ready to run a smarter planet.\n----\n\nTo access the `system` microservice, see the http://localhost:9080/system/properties[http://localhost:9080/system/properties^] URL, and you see a list of the various system properties of your JVM:\n\n[source, JSON, role=\"no_copy\"]\n----\n{\n    \"os.name\": \"Mac OS X\",\n    \"java.version\": \"1.8.0_151\",\n    ...\n}\n----\n\nWhen you need to stop the Liberty instance, press `CTRL+C` in the command-line session where you ran Liberty, or run the `liberty:stop` goal from the `start` directory in another command-line session:\n\n[role='command']\n```\nmvn liberty:stop\n```\n\n// =================================================================================================\n// Starting and stopping Open Liberty in the background\n// =================================================================================================\n\n== Starting and stopping Open Liberty in the background\n\nAlthough you can start and stop Liberty in the foreground by using the Maven `liberty:run` goal, you can also start and stop the Liberty instance in the background with the Maven `liberty:start` and `liberty:stop` goals:\n\n[role='command']\n----\nmvn liberty:start\nmvn liberty:stop\n----\n\n\n// =================================================================================================\n// Updating the runtime configuration without restarting Liberty\n// =================================================================================================\n\n== Updating Liberty's configuration without restarting\n\nThe Open Liberty Maven plug-in includes a `dev` goal that listens for any changes in the project, including application source code or configuration. The Open Liberty instance automatically reloads the configuration without restarting. This goal allows for quicker turnarounds and an improved developer experience.\n\nStop the Open Liberty instance if it is running, and start it in https://openliberty.io/docs/latest/development-mode.html[dev mode^] by running the `liberty:dev` goal in the `start` directory:\n\n[role='command']\n```\nmvn liberty:dev\n```\n\nDev mode automatically picks up changes that you make to your application and allows you to run tests by pressing the `enter/return` key in the active command-line session. When you’re working on your application, rather than rerunning Maven commands, press the `enter/return` key to verify your change.\n\nAs before, you can see that the application is running by going to the http://localhost:9080/system/properties[http://localhost:9080/system/properties^] URL.\n\nNow try updating Liberty's `server.xml` configuration file while the instance is running in dev mode. The `system` microservice does not currently include health monitoring to report whether the Liberty instance and the microservice that it runs are healthy. You can add health reports with the MicroProfile Health feature, which adds a `/health` endpoint to your application. If you try to access this endpoint now at the http://localhost:9080/health/[http://localhost:9080/health/^] URL, you see a 404 error because the `/health` endpoint does not yet exist:\n\n[source, role=\"no_copy\"]\n----\nError 404: java.io.FileNotFoundException: SRVE0190E: File not found: /health\n----\n\nTo add the MicroProfile Health feature to the Liberty instance, include the [hotspot=mpHealth]`mpHealth` feature in the [hotspot]`server.xml`.\n\n[role=\"code_command hotspot\", subs=\"quotes\"]\n----\n#Replace the Liberty `server.xml` configuration file.#\n`src/main/liberty/config/server.xml`\n----\n\nserver.xml\n[source, xml, linenums, role='code_column hide_tags=logging']\n----\ninclude::staging/server.xml[]\n----\n\nAfter you make the file changes, Open Liberty automatically reloads its configuration. When enabled, the [hotspot=mpHealth]`mpHealth` feature automatically adds a `/health` endpoint to the application. You can see the instance being updated in the Liberty log displayed in your command-line session:\n\n[source, role=\"no_copy\"]\n----\n[INFO] [AUDIT] CWWKG0016I: Starting server configuration update.\n[INFO] [AUDIT] CWWKT0017I: Web application removed (default_host): http://foo:9080/\n[INFO] [AUDIT] CWWKZ0009I: The application io.openliberty.guides.getting-started has stopped successfully.\n[INFO] [AUDIT] CWWKG0017I: The server configuration was successfully updated in 0.284 seconds.\n[INFO] [AUDIT] CWWKT0016I: Web application available (default_host): http://foo:9080/health/\n[INFO] [AUDIT] CWWKF0012I: The server installed the following features: [mpHealth-4.0].\n[INFO] [AUDIT] CWWKF0008I: Feature update completed in 0.285 seconds.\n[INFO] [AUDIT] CWWKT0016I: Web application available (default_host): http://foo:9080/\n[INFO] [AUDIT] CWWKZ0003I: The application io.openliberty.guides.getting-started updated in 0.173 seconds.\n----\n\nTry to access the `/health` endpoint again by visiting the http://localhost:9080/health[http://localhost:9080/health^] URL. You see the following JSON:\n\n[source, JSON, role=\"no_copy\"]\n----\n{\n    \"checks\":[],\n    \"status\":\"UP\"\n}\n----\n\nNow you can verify whether your Liberty instance is up and running.\n\n\n// =================================================================================================\n// Updating the source code without restarting Liberty\n// =================================================================================================\n\n== Updating the source code without restarting Liberty\n\nThe RESTful application that contains your `system` microservice runs in a Liberty instance from its `.class` file and other artifacts. Open Liberty automatically monitors these artifacts, and whenever they are updated, it updates the running instance without the need for the instance to be restarted.\n\nLook at your [hotspot file=0]`pom.xml` file.\n\npom.xml\n[source, XML, linenums, role=\"code_column\"]\n----\ninclude::finish/pom.xml[tags=**]\n----\n\nTry updating the source code while Liberty is running in dev mode. At the moment, the `/health` endpoint reports whether the Liberty instance is running, but the endpoint doesn't provide any details on the microservices that are running inside of the instance.\n\nMicroProfile Health offers health checks for both readiness and liveness. A readiness check allows third-party services, such as Kubernetes, to know if the microservice is ready to process requests. A liveness check allows third-party services to determine if the microservice is running.\n\n[role=\"code_command hotspot file=1\", subs=\"quotes\"]\n----\n#Create the `SystemReadinessCheck` class.#\n`src/main/java/io/openliberty/sample/system/SystemReadinessCheck.java`\n----\n\nSystemReadinessCheck.java\n[source, java, linenums, role='code_column hide_tags=copyright']\n----\ninclude::finish/src/main/java/io/openliberty/sample/system/SystemReadinessCheck.java[]\n----\n\nThe [hotspot=systemReadinessCheck file=1]`SystemReadinessCheck` class verifies that the \n`system` microservice is not in maintenance by checking a config property.\n\n[role=\"code_command hotspot file=2\", subs=\"quotes\"]\n----\n#Create the `SystemLivenessCheck` class.#\n`src/main/java/io/openliberty/sample/system/SystemLivenessCheck.java`\n----\n\nSystemLivenessCheck.java\n[source, java, linenums, role='code_column hide_tags=copyright']\n----\ninclude::finish/src/main/java/io/openliberty/sample/system/SystemLivenessCheck.java[]\n----\n\nThe [hotspot=systemLivenessCheck file=2]`SystemLivenessCheck` class reports a status of \n`DOWN` if the microservice uses over 90% of the maximum amount of memory.\n\nAfter you make the file changes, Open Liberty automatically reloads its configuration and the `system` application.\n\nThe following messages display in your first command-line session:\n\n[source, role=\"no_copy\"]\n----\n[INFO] [AUDIT] CWWKT0017I: Web application removed (default_host): http://foo:9080/\n[INFO] [AUDIT] CWWKZ0009I: The application io.openliberty.guides.getting-started has stopped successfully.\n[INFO] [AUDIT] CWWKT0016I: Web application available (default_host): http://foo:9080/\n[INFO] [AUDIT] CWWKZ0003I: The application io.openliberty.guides.getting-started updated in 0.136 seconds.\n----\n\nAccess the `/health` endpoint again by going to the http://localhost:9080/health[http://localhost:9080/health^] URL. This time you see the overall status of your Liberty instance and the aggregated data of the liveness and readiness checks for the `system` microservice:\n\n[source, JSON, role=\"no_copy\"]\n----\n{  \n   \"checks\":[  \n      {  \n         \"data\":{},\n         \"name\":\"SystemResource Readiness Check\",\n         \"status\":\"UP\"\n      },\n      {  \n         \"data\":{},\n         \"name\":\"SystemResource Liveness Check\",\n         \"status\":\"UP\"\n      }\n   ],\n   \"status\":\"UP\"\n}\n----\n\nYou can also access the `/health/ready` endpoint by going to the http://localhost:9080/health/ready[http://localhost:9080/health/ready^] URL to view the data from the readiness health check. Similarly, access the `/health/live` endpoint by going to the http://localhost:9080/health/live[http://localhost:9080/health/live^] URL to view the data from the liveness health check.\n\nMaking code changes and recompiling is fast and straightforward. Open Liberty dev mode automatically picks up changes in the `.class` files and artifacts, without needing to be restarted. Alternatively, you can run the `run` goal and manually repackage or recompile the application by using the `mvn package` command or the `mvn compile` command while Liberty is running. Dev mode was added to further improve the developer experience by minimizing turnaround times.\n\n\n// =================================================================================================\n// Checking the Open Liberty logs\n// =================================================================================================\n\n== Checking the Open Liberty logs\n\nWhile Liberty is running in the foreground, it displays various console messages in the command-line session. These messages are also logged to the `target/liberty/wlp/usr/servers/defaultServer/logs/console.log` file. You can find the complete Liberty logs in the `target/liberty/wlp/usr/servers/defaultServer/logs` directory. The `console.log` and `messages.log` files are the primary log files that contain console output of the running application and the Liberty instance. More logs are created when runtime errors occur or whenever tracing is enabled. You can find the error logs in the `ffdc` directory and the tracing logs in the `trace.log` file.\n\nIn addition to the log files that are generated automatically, you can enable logging of specific Java packages or classes by using the `logging` element:\n\n[source, XML, role=\"no_copy\"]\n```\n\u003clogging traceSpecification=\"\u003ccomponent_1\u003e=\u003clevel\u003e:\u003ccomponent_2\u003e=\u003clevel\u003e:...\"/\u003e\n```\n\nThe `component` element is a Java package or class, and the `level` element is one of the following logging levels: `off`, `fatal`, `severe`, `warning`, `audit`, `info`, `config`, `detail`, `fine`, `finer`, `finest`, `all`.\n\nFor more information about logging, see the https://www.openliberty.io/docs/latest/log-trace-configuration.html#log_details[Trace log detail levels^],  https://www.openliberty.io/docs/latest/reference/config/logging.html[logging element^], and https://www.openliberty.io/docs/latest/log-trace-configuration.html[Log and trace configuration^] documentation.\n\nTry enabling detailed logging of the MicroProfile Health feature by adding the [hotspot=logging]`logging` element to your configuration file.\n\n[role=\"code_command hotspot\" subs=\"quotes\"]\n----\n#Replace the Liberty `server.xml` configuration file.#\n`src/main/liberty/config/server.xml`\n----\n\nserver.xml\n[source, XML, linenums, role=\"code_column\"]\n----\ninclude::staging/server.xml[]\n----\n\nAfter you change the file, Open Liberty automatically reloads its configuration.\n\nNow, when you visit the `/health` endpoint, additional traces are logged in the `trace.log` file.\n\nifdef::cloud-hosted[]\n```bash\nls /home/project/guide-getting-started/start/target/liberty/wlp/usr/servers/defaultServer/logs\n```\nendif::[]\n\n[role='command']\ninclude::{common-includes}/devmode-quit-ctrlc.adoc[]\n\n// =================================================================================================\n// Running the application in a Docker container\n// =================================================================================================\n\n== Running the application in a Docker container\n\nifndef::cloud-hosted[]\nTo run the application in a container, Docker needs to be installed. For installation instructions, see the https://docs.docker.com/install/[Official Docker Docs^].\n\nMake sure to start your Docker daemon before you proceed.\nendif::[]\n\nTo containerize the application, you need a `Dockerfile`. This file contains a collection of instructions that define how a Docker image is built, what files are packaged into it, what commands run when the image runs as a container, and other information. You can find a complete `Dockerfile` in the `start` directory. This `Dockerfile` copies the `.war` file into a Docker image that contains the Java runtime and a preconfigured Open Liberty runtime.\n\nRun the `mvn package` command from the `start` directory so that the `.war` file resides in the `target` directory.\n\n[role='command']\n```\nmvn package\n```\n\n\n\nTo build and containerize the application, run the following Docker build command in the `start` directory:\n\n[role='command']\n```\ndocker build -t openliberty-getting-started:1.0-SNAPSHOT .\n```\n\nThe Docker `openliberty-getting-started:1.0-SNAPSHOT` image is also built from the `Dockerfile`. To verify that the image is built, run the `docker images` command to list all local Docker images:\n\n[role='command']\n```\ndocker images\n```\n\nYour image should appear in the list of all Docker images:\n\n[source, role=\"no_copy\"]\n----\nREPOSITORY                     TAG             IMAGE ID        CREATED         SIZE\nopenliberty-getting-started    1.0-SNAPSHOT    88173351adfa    2 minutes ago   780MB\n----\n\nNext, run the image as a container:\n[role='command']\n```\ndocker run -d --name gettingstarted-app -p 9080:9080 openliberty-getting-started:1.0-SNAPSHOT\n```\n\nThere is a bit going on here, so here's a breakdown of the command:\n\n[cols=\"15, 100\", options=\"header\"]\n|===\n| *Flag* | *Description*\n| -d     | Runs the container in the background.\n| --name | Specifies a name for the container.\n| -p     | Maps the container ports to the host ports.\n|===\n\nThe final argument in the `docker run` command is the Docker image name.\n\nNext, run the `docker ps` command to verify that your container started:\n[role='command']\n```\ndocker ps\n```\n\nMake sure that your container is running and does not have `Exited` as its status:\n\n[source, role=\"no_copy\"]\n----\nCONTAINER ID    IMAGE                         CREATED          STATUS           NAMES\n4294a6bdf41b    openliberty-getting-started   9 seconds ago    Up 11 seconds    gettingstarted-app\n----\n\nTo access the application, go to the http://localhost:9080/system/properties[http://localhost:9080/system/properties^] URL.\n\nTo stop and remove the container, run the following commands:\n[role='command']\n```\ndocker stop gettingstarted-app \u0026\u0026 docker rm gettingstarted-app\n```\n\nTo remove the image, run the following command:\n[role='command']\n```\ndocker rmi openliberty-getting-started:1.0-SNAPSHOT\n```\n\n// =================================================================================================\n// Developing the application in a Docker container\n// =================================================================================================\n\n== Developing the application in a Docker container\n\nThe Open Liberty Maven plug-in includes a `devc` goal that simplifies developing your application in a Docker container by starting dev mode with container support. This goal builds a Docker image, mounts the required directories, binds the required ports, and then runs the application inside of a container. Dev mode also listens for any changes in the application source code or configuration and rebuilds the image and restarts the container as necessary.\n\nBuild and run the container by running the devc goal from the `start` directory:\n\n// Static guide instruction\nifndef::cloud-hosted[]\n[role='command']\n```\nmvn liberty:devc\n```\nendif::[]\n\n// Cloud hosted guide instruction\nifdef::cloud-hosted[]\n```bash\nchmod 777 /home/project/guide-getting-started/start/target/liberty/wlp/usr/servers/defaultServer/logs\nmvn liberty:devc -DserverStartTimeout=300\n```\nendif::[]\n\nWhen you see the following message, Open Liberty is ready to run in dev mode:\n\n[source, role=\"no_copy\"]\n----\n**************************************************************\n*    Liberty is running in dev mode.\n----\n\nOpen another command-line session and run the `docker ps` command to verify that your container started:\n[role='command']\n```\ndocker ps\n```\n\nYour container should be running and have `Up` as its status:\n\n[role=\"no_copy\"]\n----\nCONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS                         PORTS                                                                    NAMES\n17af26af0539        guide-getting-started-dev-mode        \"/opt/ol/helpers/run…\"   3 minutes ago       Up 3 minutes                   0.0.0.0:7777-\u003e7777/tcp, 0.0.0.0:9080-\u003e9080/tcp, 0.0.0.0:9443-\u003e9443/tcp   liberty-dev\n----\n\nTo access the application, go to the http://localhost:9080/system/properties[http://localhost:9080/system/properties^] URL. \n\nDev mode automatically picks up changes that you make to your application and allows you to run tests by pressing the `enter/return` key in the active command-line session.\n\nUpdate the [hotspot file=0]`server.xml` file to change the context root from `/` to [hotspot=webApplication file=0]`/dev`.\n\n[role=\"code_command hotspot file=0\", subs=\"quotes\"]\n----\n#Replace the Liberty `server.xml` configuration file.#\n`src/main/liberty/config/server.xml`\n----\n\n// File 0\nserver.xml\n[source, xml, linenums, role='code_column']\n----\ninclude::finish/src/main/liberty/config/server.xml[]\n----\n\nAfter you make the file changes, Open Liberty automatically reloads its configuration. When you see the following message in your command-line session, Open Liberty is ready to run again:\n\n[source, role=\"no_copy\"]\n----\nThe server has been restarted.\n************************************************************************\n*    Liberty is running in dev mode.\n----\n\nUpdate the [hotspot file=1]`mpData.js` file to change the [hotspot=jsUrl file=1]`url` in the [hotspot=getSystemPropertiesRequest file=1]`getSystemPropertiesRequest` method to reflect the new context root.\n\n// Static guide instruction\nifndef::cloud-hosted[]\n[role=\"code_command hotspot file=1\" subs=\"quotes\"]\n----\n#Replace the mpData.js file.#\n`src/main/webapp/js/mpData.js`\n----\n\nmpData.js\n[source, javascript, linenums, role='code_column hide_tags=copyright']\n----\ninclude::finish/src/main/webapp/js/mpData.js[]\n----\nendif::[]\n\n// Cloud hosted guide instruction\nifdef::cloud-hosted[]\nUpdate the mpData.js file.\n\n\u003e From the menu of the IDE, select \n\u003e ***File*** \u003e ***Open*** \u003e guide-getting-started/start/src/main/webapp/js/mpData.js, or click the following button\n\n::openFile{path=\"/home/project/guide-getting-started/start/src/main/webapp/js/mpData.js\"}\n\n```\nfunction getSystemPropertiesRequest() {\n    var propToDisplay = [\"java.vendor\", \"java.version\", \"user.name\", \"os.name\", \"wlp.install.dir\", \"wlp.server.name\" ];\n    var url = \"http://localhost:9080/dev/system/properties\";\n    var req = new XMLHttpRequest();\n    var table = document.getElementById(\"systemPropertiesTable\");\n    ...\n```\nendif::[]\n\nUpdate the [hotspot file=2]`pom.xml` file to change the context root from `/` to [hotspot=contextRoot file=2]`/dev` in the [hotspot=maven-failsafe-plugin file=2]`maven-failsafe-plugin` to reflect the new context root when you run functional tests.\n\n[role=\"code_command hotspot file=2\" subs=\"quotes\"]\n----\n#Replace the pom.xml file.#\n`pom.xml`\n----\n\npom.xml\n[source, XML, linenums, role='code_column hide_tags=copyright']\n----\ninclude::finish/pom.xml[]\n----\n\nYou can run the tests by pressing the `enter/return` key from the command-line session where you started dev mode to verify your change.\n\nYou can access the application at the http://localhost:9080/dev/system/properties[http://localhost:9080/dev/system/properties^] URL. Notice that the context root is now `/dev`.\n\nWhen you are finished, exit dev mode by pressing `CTRL+C` in the command-line session that the container was started from. Exiting dev mode stops and removes the container. To check that the container was stopped, run the `docker ps` command.\n\n// =================================================================================================\n// Running the application from a minimal runnable JAR\n// =================================================================================================\n\n== Running the application from a minimal runnable JAR\n\nSo far, Open Liberty was running out of the `target/liberty/wlp` directory, which effectively contains an Open Liberty installation and the deployed application. The final product of the Maven build is a server package for use in a continuous integration pipeline and, ultimately, a production deployment.\n\nOpen Liberty supports a number of different server packages. The sample application currently generates a `usr` package that contains the Liberty runtime and application to be extracted onto an Open Liberty installation.\n\nInstead of creating a server package, you can generate a runnable JAR file that contains the application along with a Liberty runtime. This JAR file can then be run anywhere and deploy your application and runtime at the same time. To generate a runnable JAR file, override the  `include` property: \n[role='command']\n```\nmvn liberty:package -Dinclude=runnable\n```\n\nThe packaging type is overridden from the `usr` package to the `runnable` package. This property then propagates to the [hotspot=libertyMavenPlugin file=0]`liberty-maven-plugin` plug-in, which generates the server package based on the `openliberty-kernel` package.\n\nWhen the build completes, you can find the minimal runnable `guide-getting-started.jar` file in the `target` directory. This JAR file contains only the [hotspot=features file=1]`features` that you explicitly enabled in your [hotspot file=1]`server.xml` file. As a result, the generated JAR file is only about 50 MB.\n\nTo run the JAR file, first stop the Liberty instance if it's running. Then, navigate to the `target` directory and run the `java -jar` command:\n\n[role='command']\n```\njava -jar guide-getting-started.jar\n```\n\nWhen Liberty starts, go to the http://localhost:9080/dev/system/properties[http://localhost:9080/dev/system/properties^] URL to access your application that is now running out of the minimal runnable JAR file.\n\nYou can stop the Liberty instance by pressing `CTRL+C` in the command-line session that the instance runs in.\n\npom.xml\n[source, XML, linenums, role=\"code_column\"]\n----\ninclude::finish/pom.xml[]\n----\n\nserver.xml\n[source, xml, linenums, role='code_column']\n----\ninclude::finish/src/main/liberty/config/server.xml[]\n----\n\n\n// =================================================================================================\n// Great work! You're done!\n// =================================================================================================\n\n== Great work! You're done!\n\nYou've learned the basics of deploying and updating an application on Open Liberty.\n\n\ninclude::{common-includes}/attribution.adoc[subs=\"attributes\"]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenliberty%2Fguide-getting-started","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenliberty%2Fguide-getting-started","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenliberty%2Fguide-getting-started/lists"}