Skip to content

Quick Start

Install JeKa

Note

Using the IntelliJ Plugin is the fastest way to get started. It provides a wizard for creating various types of projects, ranging from simple scripts to full-fledged Spring Boot applications.

Follow the Guide

This quick-start guide covers multiple use cases:

Note

If you are coding in IntelliJ IDEA, after scaffolding or modifying dependencies, execute the following command to synchronize:

jeka intellij: sync

Create Scripts

Create a directory to host the codebase. Navigate into it and execute:

jeka base: scaffold
This generates a structure as:
.                        <- Project root directory
├── jeka-src             <- Source dir for JeKa scripts and configuration code
│   └── Script.java     
└── jeka.properties      <- JeKa configuration (Java and JeKa version, default parameters...)
Ths script class looks like:
@JkDoc("Minimalist script for demo purpose.")
class Script extends KBean {

    @JkDoc("Person to whom the greeting is intended")
    public String name = "World";

    @JkDoc("Print greeting on console")
    public void hello() {
        String greetings = "Hello " + name + " !";
        System.out.println(greetings);
    }
}

Run methods

You can run the method hello() and change the parameter, by executing:

jeka hello name="JeKa"
This displays the following text on the console:
Hello JeKa !

Write Extra Methods

You can add extra methods relying or not on third-party dependencies as:

import com.github.lalyos.jfiglet.FigletFont;
import com.google.common.base.Strings;
import dev.jeka.core.tool.JkDep;
import dev.jeka.core.tool.KBean;

@JkDep("com.github.lalyos:jfiglet:0.0.9")
@JkDep("com.google.guava:guava:33.3.1-jre")
class Script extends KBean {

    public void header() throws Exception {
        System.out.println(Strings.repeat("-", 80));
        System.out.println(FigletFont.convertOneLine("Hello Ascii Art !"));
        System.out.println(Strings.repeat("-", 80));
    }
}
Execute:
jeka header
This will display the following text on the console:
--------------------------------------------------------------------------------
  _   _      _ _            _             _ _      _         _     _ 
 | | | | ___| | | ___      / \   ___  ___(_|_)    / \   _ __| |_  | |
 | |_| |/ _ \ | |/ _ \    / _ \ / __|/ __| | |   / _ \ | '__| __| | |
 |  _  |  __/ | | (_) |  / ___ \\__ \ (__| | |  / ___ \| |  | |_  |_|
 |_| |_|\___|_|_|\___/  /_/   \_\___/\___|_|_| /_/   \_\_|   \__| (_)


--------------------------------------------------------------------------------

Note

  • You can define multiple script methods in Script.java. These methods must be public, non-static, take no arguments, and return void.
  • You can rename Script.java to any name and place it in any package.
  • You can create multiple script classes. To run a specific script, use the class name, e.g., jeka script2: hi.
  • You can also use classes provided by JeKa without explicitly declaring them.

KBeans

Every script should inherit from the KBean class.

KBeans can either be provided as source code (located in the jeka-src directory) or as compiled classes available in the classpath.

JeKa includes several standard KBeans, which you can list by running:

jeka --doc

Change Java Version

To change version of Java, edit jeka.properties:

jeka.java.version=23
This will automatically download Java 23 (if not already installed) on the next method run.

Run remotely

Run hello from another directory:

jeka -r /path/to/script/root-dir hello

Run hello from remote git repo:

jeka -r https://my.githost/my-repo.git hello

Common Options/Commands:

jeka --help          <- Displays help message
--doc                <- Displays documentation on available scripts
--inspect            <- Displays details about JeKa setup
jeka base: depTree   <- Show dependency tree

Resources

Create a Base App or Library

JeKa provides a base mode, which simplifies the creation of pure Java applications or libraries by avoiding the complexity of a traditional project structure.

Despite its simplicity, this structure supports full build configuration, automated testing, native compilation, Maven publication, and Docker image creation.

To create a new code structure, run the following command:

jeka base: scaffold scaffold.kind=APP
This creates a structure like this:
. 
├── jeka-src             <- Source root directory
│   ├── _dev             <- Optional package containing all non-prod (build and test)
│   │   ├── test
│   │   └── Build.java  
│   └── app              <- Suggested base package for production code/resources
│       └── App.java     
├── jeka-output          <- Generated dir where artifacts as jars, classes, reports or doc are generated
├── jeka.properties      <- Build configuration (Java and JeKa version, KBean configurations, ...)
└── README.md            <- Describes available build commands

Follow the tutorial for more details.

Create a Java Project

In this mode, you can create a fully-fledged project similar to Maven or Gradle.

To create a new project structure, execute:

jeka project: scaffold
This generates a project structure as:
.
├── src                  
│   ├── main             <- Java code and resources
│   │   ├── java
│   │   └── resources    
│   └── test             <- Java code and resources for tests
│       ├── java
│       └── resources 
├── jeka-src             <- Optional Java (or Kotlin) code for building the project
│   └── Build.java      
├── jeka-output          <- Generated dir where artifacts as jars, classes, reports or doc are generated
├── dependencies.txt     <- Dependency lists for compile, runtime and testing
├── jeka.properties      <- Build configuration (Java and JeKa version, KBean configurations, ...)
├── jeka.ps              <- Optional PowerShell script to boot JeKa on Windows
├── jeka                 <- Optional bash script to boot JeKa on Linux/MacOS
└── README.md            <- Describes available build commands for building the project

Follow the tutorial for more details.

Create a Spring Boot Project

To create a new Spring Boot project, execute:

jeka -cp=dev.jeka:springboot-plugin project: scaffold springboot:

This generates the following project structure:

.
├── src                  
│   ├── main             
│   │   ├── java
│   │   │   └── app
│   │   │       ├── Application.java.     <- Spring Boot app class
│   │   │       └── Controller.java.      <- REST controller
│   │   └── resources    
│   └── test             
│       ├── java
│       │   └── app
│       │       └── ControllerIt.java     <- Integration Test for REST controller 
│       └── resources 
├── jeka-src             
│   └── Build.java       <- Empty build class - in case of.
├── jeka-output         
├── dependencies.txt     <- Spring Boot and extra dependencies
├── jeka.properties      <- Build configuration 
├── jeka.ps              
├── jeka                 
└── README.md            <- Describes available build commands for building the project
This contains a minimal workable project with production and test code.

Modify Layout

You can choose a simpler code layout structure by setting the following properties:

jeka.properties
@project.layout.style=SIMPLE
@project.layout.mixSourcesAndResources=true
You'll end up with the following code layout:
.
├── src       <- Contains both Java code and resources    
├── test      <- Contains both Java code and resources for testing

Modify Dependencies

The dependencies are generated with the latest Spring Boot version:

dependencies.txt
[version]
org.springframework.boot:spring-boot-dependencies:3.4.1@pom

[compile]
org.springframework.boot:spring-boot-starter-web

[test]
org.springframework.boot:spring-boot-starter-test
You can start from here for modifying, adding code, tests and dependencies.

Execute Commands

These are the most useful commands for developing Spring Boot applications.

Common Commands
jeka project: test       <- Compiles and run tests
jeka project: pack       <- Compiles and creates Bootable Jar
jeka project: runJar     <- Run bootable jar
jeka project: build      <- All-in-one to compile, test, pack, run analysis and end-to-end test
jeka project: depTree    <- Displays dependency tree

jeka docker: build       <- Creates Docker image containing the Spring Boot application
jeka docker: buildNative <- Creates Docker image containing the Spring Boot application compiled to native.

Customize Docker File

To reduce a Docker native image size, use a distroless base image. The native executable must be statically linked as libc is unavailable in such distributions. Configure it as follows:

jeka.properties
@native.staticLink=MUSL
@docker.nativeBaseImage=gcr.io/distroless/static-debian12:nonroot

What Next?

Now that you're here, you can explore the following resources to enhance your project. Learn how to include SonarQube analysis, add a ReactJS web client, perform end-to-end testing, or implement a delivery pipeline in Java: