<commit_before>
[id='creating-an-application-from-scratch_{context}']
= Creating an application from scratch

Creating a simple {Thorntail}{ndash}based application with a REST endpoint from scratch.

[discrete]
== Prerequisites

* JDK 8 or newer installed
* Maven 3.3.x or newer installed

[discrete]
== Procedure

. Create a directory for the application and navigate to it:
+
--
[source,bash,options="nowrap"]
----
$ mkdir myApp
$ cd myApp
----

We recommend you start tracking the directory contents with Git.
For more information, see https://git-scm.com/docs/gittutorial[Git tutorial].
--

. In the directory, create a `pom.xml` file with the following content.
+
[source,xml,options="nowrap",subs="attributes+"]
----
ifndef::product[]
include::src/main/resources/pom.xml[]
endif::[]
ifdef::product[]
include::src/main/resources/pom-product.xml[]
endif::[]
----

. Create a directory structure for your application:
+
[source,bash,options="nowrap"]
----
mkdir -p src/main/java/com/example/rest
----

. In the `src/main/java/com/example/rest` directory, create the source files:
** `HelloWorldEndpoint.java` with the class that serves the HTTP endpoint:
+
[source,java,options="nowrap"]
----
include::src/main/resources/HelloWorldEndpoint.java[]
----

** `RestApplication.java` with the application context:
+
[source,java,options="nowrap"]
----
include::src/main/resources/RestApplication.java[]
----

. Execute the application using Maven:
+
[source,bash,options="nowrap"]
----
$ mvn thorntail:run
----

[discrete]
== Results

Accessing the `http://localhost:8080/rest/hello` URL in your browser should return the following message:

[source,subs="attributes+"]
----
Hello from {Thorntail}!
----

After finishing the procedure, there should be a directory on your hard drive with the following contents:

[source,options="nowrap"]
----
myApp
├── pom.xml
└── src
    └── main
        └── java
            └── com
                └── example
                    └── rest
                        ├── HelloWorldEndpoint.java
                        └── RestApplication.java
----
<commit_msg>remove references to specific maven an JDK versions<commit_after>
[id='creating-an-application-from-scratch_{context}']
= Creating an application from scratch

Creating a simple {Thorntail}{ndash}based application with a REST endpoint from scratch.

[discrete]
== Prerequisites

* JDK installed
* Maven installed

[discrete]
== Procedure

. Create a directory for the application and navigate to it:
+
--
[source,bash,options="nowrap"]
----
$ mkdir myApp
$ cd myApp
----

We recommend you start tracking the directory contents with Git.
For more information, see https://git-scm.com/docs/gittutorial[Git tutorial].
--

. In the directory, create a `pom.xml` file with the following content.
+
[source,xml,options="nowrap",subs="attributes+"]
----
ifndef::product[]
include::src/main/resources/pom.xml[]
endif::[]
ifdef::product[]
include::src/main/resources/pom-product.xml[]
endif::[]
----

. Create a directory structure for your application:
+
[source,bash,options="nowrap"]
----
mkdir -p src/main/java/com/example/rest
----

. In the `src/main/java/com/example/rest` directory, create the source files:
** `HelloWorldEndpoint.java` with the class that serves the HTTP endpoint:
+
[source,java,options="nowrap"]
----
include::src/main/resources/HelloWorldEndpoint.java[]
----

** `RestApplication.java` with the application context:
+
[source,java,options="nowrap"]
----
include::src/main/resources/RestApplication.java[]
----

. Execute the application using Maven:
+
[source,bash,options="nowrap"]
----
$ mvn thorntail:run
----

[discrete]
== Results

Accessing the `http://localhost:8080/rest/hello` URL in your browser should return the following message:

[source,subs="attributes+"]
----
Hello from {Thorntail}!
----

After finishing the procedure, there should be a directory on your hard drive with the following contents:

[source,options="nowrap"]
----
myApp
├── pom.xml
└── src
    └── main
        └── java
            └── com
                └── example
                    └── rest
                        ├── HelloWorldEndpoint.java
                        └── RestApplication.java
----
{'fraction_non_alphanumeric': 0.15153681200857755, 'fraction_numerical': 0.0026209197045508697, 'mean_word_length': 3.4517497348886534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7657115', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1260, 'n_words': 363}