This repository demonstrates the capability of JeKa for executing Java applications from source code hosted in a remote repository.
The application is a Cowsay Java port, built with JeKa.
The project is forked from this repository and consists of many Java source and resource files.
Install JeKa. No need to have any JDK installed on your machine; JeKa manages it for you.
You don't need to clone the repo yourself. Just execute the following command:
jeka -r https://github.com/jeka-dev/demo-cowsay -p "Hello JeKa"Behind the scenes, this:
- Clones the repo in [USER HOME]/.jeka/cache/git/github.com_jeka-dev_demo-cowsay
- Downloads the proper JDK (if needed)
- Downloads the proper JeKa version (if needed)
- Builds the fat jar silently (due to the
--quietoption mentioned in the jeka.properties file) - Executes the built jar with the specified program arguments (after the
-poption).
On subsequent runs, this will execute faster as only the last step will be performed.
____________
< Hello JeKa >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
You can specify a particular tag for cloning the application using the hash notation like this:
jeka -r https://github.com/jeka-dev/demo-cowsay#0.0.8 -p "Hello JeKa"This clones the repo from tag 0.0.2 in [USER HOME]/.jeka/cache/git/github.com_jeka-dev_demo-cowsay#0.0.2.
You need to have a Docker client running on the host machine (e.g., Docker Desktop).
First, build the Docker image:
jeka -r https://github.com/jeka-dev/demo-cowsay docker: buildThen run the image:
docker run --rm github.com_jeka-dev_demo-cowsay:latest "Hello Docker" ____________
< Hello Docker >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Create an executable native executable:
jeka -r https://github.com/jeka-dev/demo-cowsay native: compile Now, run again:
jeka -r https://github.com/jeka-dev/demo-cowsay -p -f dragon "Hello Native"The native executable will run directly in a few milliseconds.
_____________
< Hello Native >
-------------
\ / \ //\
\ |\___/| / \// \\
/0 0 \__ / // | \ \
/ / \/_/ // | \ \
@_^_@'/ \/_ // | \ \
//_^_/ \/_ // | \ \
( //) | \/// | \ \
( / /) _|_ / ) // | \ _\
( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-.
(( / / )) ,-{ _ `-.|.-~-. .~ `.
(( // / )) '/\ / ~-. _ .-~ .-~^-. \
(( /// )) `. { } / \ \
(( / )) .----~-.\ \-' .~ \ `. \^-.
///.----..> \ _ -~ `. ^-` ^-_
///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~
/.-~
We can use predefined program args using interpolation defined in the jeka.properties file.
jeka -r https://github.com/jeka-dev/demo-cowsay -p ::hiBy adding jeka.cmd.cowsay=-r https://github.com/jeka-dev/demo-cowsay -p to the [USER HOME]/.jeka/global.properties file, we can use simpler typing:
jeka ::cowsayTip
You can display which shorthands are defined by executing jeka --doc.