Skip to content

Setup

You need a JDK 8 or higher installed on your machine. To determine the JDK to run upon, jeka looks in priority order :

  • JEKA_JDK environment variable ([JEKA_JDK]/bin/java must point on java executable)
  • JAVA_HOME environment variable
  • java executable accessible from PATH environment variable.

Note

Jeka organization provides a plugin for IntelliJ in order to make 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 already containing the Jeka wrapper.

Install Jeka Distribution

Note

It is not required to install Jeka distribution to use it. If you fetch a project already holding a wrapper, using jekaw would be enough. Nevertheless, if you want to create project from scractch, it will be required.

  • Download the latest release from 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 jeka command from everywhere.

Projects with Jeka Wrapper

For working on a project already holding a Jeka wrapper, there is no need to install Jeka :

  • Fetch the project from its remote repository
  • Use jekaw command from project root path.

Note

To start from an empty project, clone template blank project from https://github.com/jerkar/jeka-wrapper-project-template.git

Setup IDE

  • Add an IDE path variable JEKA_USER_HOME pointing on [USER HOME]/.jeka. In Intellij : Settings... | Appearance & Behavior | Path Variables
  • If you use jeka instead of jekaw, add an IDE path variable JEKA_HOME pointing on [JEKA HOME].

Hello World Project

For simplicity's sake, we'll use trivial example just displaying a message on 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#run if using the template wrapper project).
  • Execute jeka intellij#iml or jeka eclipse#files in order to generate 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 require to be zero-args instance methods returning void.

Modify the def/Build.java file to ad hello method as follow.

import dev.jeka.core.tool.JkBean;
import dev.jeka.core.tool.JkInit;

class Build extends JkBean {

    public void hello() {
        System.out.println("Hello world !");
    }

    public static void main(String[] args) throws Exception {
        Build build = JkInit.instanceOf(Build.class, args);
        build.hello();
    }

}

Now, execute jeka hello to see message displayed on console.

Optionally, we can use a classical main method to launch it from the IDE.

Get Contextual Help

Execute jeka -h (or jeka -help) to display a contextual help on the console.

Follow instructions to navigate to more specific help context.

Warning

Do not confuse jeka -help and jeka help. The last provides only documentation about the default KBean.

Customization

For any reasons, we might like to use different location than the standard ones for Jeka User Home and Jeka Cache.

We can change the location using following OS environment variable :

  • 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)