The generation of the executable jar file can be performed by issuing the following command
mvn clean compile quarkus:build
This will create a jar file quarkus-runner.jar within the target maven folder. This can be started by executing the following command
java -jar target/quarkus-runner.jar
You can also start the project in development mode where it automatically updates code on the fly as you save your files:
mvn clean compile quarkus:dev
Last but not least, you can build the whole application into a one statically linked executable that does not require JVM:
mvn clean compile quarkus:native-image -Pnative
Native executable build might take a minute. Then you can execute it on a compatible architecture without JVM:
./target/quarkus-runner
To launch the test page, open your browser at the following URL
http://localhost:8080/index.html
- You need GraalVM installed from the GraalVM web site. Using the community edition is enough. Version 19.1.1+ is required.
- The GRAALVM_HOME environment variable configured appropriately
- The native-image tool must be installed; this can be done by running
gu install native-image
from your GraalVM directory - To read more about Quarkus and Native image, see https://quarkus.io/guides/building-native-image-guide
karm@local:/tmp$ rm cookie.txt
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 11
Hello Worldkarm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/me
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
Content-Length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/data/hello/me; Path=/
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/admin
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
Content-Length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/data/hello/admin; Path=/
karm@local:/tmp$ ^C
karm@local:/tmp$ ^C
^C
karm@local:/tmp$ rm cookie.txt
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 11
Hello Worldkarm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/me
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
Content-Length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/data/hello/me; Path=/
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/admin
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
Content-Length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/data/hello/admin; Path=/
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/index.html
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
content-length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/index.html; Path=/
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/secret/protected.html
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
content-length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/secret/protected.html; Path=/
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/index.html^C
karm@local:/tmp$ curl -i -X POST -b cookie.txt -c cookie.txt --data 'j_username=karm&j_password=jboss' http://localhost:8080/j_security_check;echo;cat cookie.txt
HTTP/1.1 302 Found
location: http://localhost:8080/secret/protected.html
content-length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/secret/protected.html; Max-Age=0; Expires=Fri, 21 Feb 2020 14:17:28 GMT
set-cookie: quarkus-credential=DKS96LcI1vaI7EJcLkMBmS8yLnyURBRYEae49dFW7VfXLt0e9l/FXJEdA315u58=; Path=/
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
localhost FALSE / FALSE 1582294648 quarkus-redirect-location http://localhost:8080/secret/protected.html
localhost FALSE / FALSE 0 quarkus-credential DKS96LcI1vaI7EJcLkMBmS8yLnyURBRYEae49dFW7VfXLt0e9l/FXJEdA315u58=
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/secret/protected.html
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Fri, 21 Feb 2020 14:15:35 GMT
Content-Length: 159
Accept-Ranges: bytes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This is protected!</title>
</head>
<body>
<h2>Protected site</h2>
</body>
</html>karm@local:/tmp$ curlGET -b cookie.txt -c cookie.txt http://localhost:8080/index.html
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Fri, 21 Feb 2020 14:15:35 GMT
Content-Length: 225
Accept-Ranges: bytes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This is my index</title>
</head>
<body>
<h2>Who Are you?</h2>
<a href="data/hello" target="_blank" >Hello JAX-RS endpoint</a> <br/>
</body>
</html>karm@local:/tmp$ curlGET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/admin
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 14
Hello admin :)karm@local:/tmGET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/me
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 4
karmkarm@local:/tmp$ rm cookie.txt
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/admin
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
Content-Length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/data/hello/admin; Path=/
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/me
HTTP/1.1 302 Found
Location: http://localhost:8080/login.html
Content-Length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/data/hello/me; Path=/
karm@local:/tmp$ curl -i -X POST -b cookie.txt -c cookie.txt --data 'j_username=rakiz&j_password=1234' http://localhost:8080/j_security_check;echo;cat cookie.txt
HTTP/1.1 302 Found
location: http://localhost:8080/data/hello/me
content-length: 0
set-cookie: quarkus-redirect-location=http://localhost:8080/data/hello/me; Max-Age=0; Expires=Fri, 21 Feb 2020 14:18:25 GMT
set-cookie: quarkus-credential=DPPMmjKq+jKYl4Y2R+TDAa0C1HqtZ+YwMuXS/QEygGdfOXqlK2BRhxjW3FL3VE4b; Path=/
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
localhost FALSE / FALSE 1582294705 quarkus-redirect-location http://localhost:8080/data/hello/me
localhost FALSE / FALSE 0 quarkus-credential DPPMmjKq+jKYl4Y2R+TDAa0C1HqtZ+YwMuXS/QEygGdfOXqlK2BRhxjW3FL3VE4b
karm@local:/tmp$ curl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/me
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 5
rakizkarm@local:/tmp$ curl -GET -b cookie.txt -c cookie.txt http://localhost:8080/data/hello/admin
HTTP/1.1 403 Forbidden
Content-Type: application/octet-stream
Content-Length: 9
Forbiddenkarm@loccurl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/index.html
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Fri, 21 Feb 2020 14:15:35 GMT
Content-Length: 225
Accept-Ranges: bytes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This is my index</title>
</head>
<body>
<h2>Who Are you?</h2>
<a href="data/hello" target="_blank" >Hello JAX-RS endpoint</a> <br/>
</body>
</html>karm@localcurl -i -X GET -b cookie.txt -c cookie.txt http://localhost:8080/secret/protected.html
HTTP/1.1 403 Forbidden
content-length: 0