You must have a JDK 8 or higher installed on your machine. To determine the JDK to run upon, jeka prioritizes the following, in order :
- JEKA_JDK environment variable ([JEKA_JDK]/bin/java must point on java executable)
- jeka.jdk.XX property definied in [JEKA_USER_DIR]/global.properties, if a jeka.java.version=XX property is defined in [PROJECT_ROOT]/jeka/local.properties file.
- JAVA_HOME environment variable
- java executable accessible from PATH environment variable.
Jeka organization provides a plugin for IntelliJ in order to render the following tasks useless.
Here, we'll focus only on how to do it using command line only.
There are two ways of using jeka : by installing Jeka itself, or by using a project that already contains the Jeka wrapper.
Install Jeka Distribution¶
It is not required to install Jeka distribution to use it. If you fetch a project that already contains a wrapper, using
jekaw will be enough.
Nevertheless, if you want to create a project from scratch, installation will be necessary.
- Download the latest release here and unpack the distrib.zip wherever you want on your machine. We'll refer to this directory as [JEKA HOME].
- Add [JEKA HOME] to your PATH environment variable.
- Now, you can use the
jekacommand from everywhere.
Projects with Jeka Wrapper¶
There is no need to install Jeka to work a project already holding a Jeka wrapper:
- Fetch the project from its remote repository
- Use the
jekawcommand from the project root path.
To start from an empty project, clone the blank project template from https://github.com/jerkar/jeka-wrapper-project-template.git
- Add an IDE path variable JEKA_USER_HOME pointing on [USER HOME]/.jeka. In Intellij : Settings... | Appearance & Behavior | Path Variables
- If you use
jekaw, add an IDE path variable JEKA_HOME pointing on [JEKA HOME].
Hello World Project¶
For simplicity's sake, we'll use the basic example of displaying a message on the console.
Create Project Structure¶
- Create the root dir of the project or use the template wrapper project mentioned above.
- At project root, execute
jeka scaffold#run scaffold#wrapper(or just
jekaw scaffold#runif using the template wrapper project).
jeka eclipse#filesin order to generate the IDE configuration file.
- The project with a Jeka structure and a basic build class is ready to work within your IDE
Create a Jeka Method¶
Jeka methods must be zero-args instance methods returning
Modify the def/Build.java file to add the hello method as follows.
jeka hello to see the message displayed on the console.
Optionally, you can also use the classical
main method to launch it from the IDE.
Get Contextual Help¶
jeka -h (or
jeka -help) to display contextual help on the console.
Follow the instructions to navigate to more specific help.
Do not confuse
jeka -help and
jeka #help. The latter only provides documentation about the default KBean.
For any reason, we might use different locations than the standard ones for Jeka User Home and Jeka Cache.
We can change the location using the following OS environment variables :
JEKA_USER_HOME: to set the Jeka User Home to a specified location (absolute path).
JEKA_CACHE_DIR: to set the cache (mainly all downloaded files), to a specified location (absolute path)
Or setting the following System properties :
jeka.cache.dir: to set the cache (mainly all downloaded files), to a specified location (absolute path)