Jenetics is an advanced Genetic Algorithm, respectively an Evolutionary Algorithm, library written in modern day Java.

zip tar.gz Maven

Currently v3.8.0

Jenetics is designed with a clear separation of the several concepts of the algorithm, e.g. Gene, Chromosome, Genotype, Phenotype, Population and fitness Function. Jenetics allows you to minimize and maximize the given fitness function without tweaking it. In contrast to other GA implementations, the library uses the concept of an evolution stream (EvolutionStream) for executing the evolution steps. Since the EvolutionStream implements the Java Stream interface, it works smoothly with the rest of the Java Stream API.


Frictionless minimization

No need to tweak the fitness function for minimization problems. Just change the configuration of the evolution Engine.

Plugable PRNG

Easy changeable PRNG (RandomRegistry). No special PRNG interface; the standard Java Random engine allows the use of existing random generators.

Parallel processing support

Processing of the evolutionary steps can be executed in parallel!

Dependency free

No runtime dependencies to Third Party libraries! No mismatch and class loading problems with other libraries.

Java 8 ready

Fully support of Java 8 Streams and Lambdas!

Fully documented

Complete Documentation and User guide available, including documentation of selected implementation details.



  • JRE 8: Java runtime version 8 is needed for using the library, respectively for running the examples.

Build time

  • JDK 8: The JAVA_HOME variable must be set to your Java installation directory.
  • Gradle 2.x: Gradle is used for building the library. (Gradle is download automatically, if you are using the Gradle Wrapper script,

    $ gradlew
    located in the base directory, for building the library.)

Test compile/execution

  • TestNG 6.11: Jenetics uses TestNG framework for unit tests.
  • Apache Commons Math 3.6: Library is used for testing statistical collectors in the org.jenetics.stat package.

Build Jenetics

For building the Jenetics library from source, download the most recent, stable package version from Sourceforge and extract it to some build directory.

$ unzip jenetics-<version>.zip -d <builddir>

<version> denotes the actual Jenetics version and <builddir> the actual build directory. Alternatively you can clone the current version from Github.

$ git clone <builddir>

Jenetics uses Gradle as build system and organizes the source into sub-projects (modules). Each sub-project is located in it’s own sub-directory:

  • org.jenetics: This project contains the source code and tests for the Jenetics core-module.
  • org.jenetics.example: This project contains example code for the core-module.
  • org.jenetics.doc: Contains the code of the web-site and the manual.

For building the library change into the <builddir> directory (or one of the module directory) and call one of the available tasks:

  • compileJava: Compiles the Jenetics sources and copies the class files to the <builddir>/<module-dir>/build/classes/main directory.
  • jar: Compiles the sources and creates the JAR files. The artifacts are copied to the <builddir>/<module-dir>/build/libs directory.
  • javadoc: Generates the API documentation. The Javadoc is stored in the <builddir>/<module-dir>/build/docs directory
  • test: Compiles and executes the unit tests. The test results are printed onto the console and a test-report, created by TestNG, is written to <builddir>/<module-dir> pre directory.
  • clean: Deletes the <builddir>/build/* directories and removes all generated artifacts.

For building the library jar from the sources call

$ cd <build-dir>
$ ./gradlew jar

IDE Integration

Gradle has tasks which creates the project file for Eclipse and IntelliJ IDEA. Call

$ ./gradlew [eclipse|idea]

for creating the project files for Eclipse or IntelliJ, respectively.


The minimum evolution Engine setup needs a genotype factory, Factory<Genotype<?>>, and a fitness Function. The Genotype implements the Factory interface and can therefore be used as prototype for creating the initial Population and for creating new random Genotypes.

import org.jenetics.BitChromosome;
import org.jenetics.BitGene;
import org.jenetics.Genotype;
import org.jenetics.engine.Engine;
import org.jenetics.engine.EvolutionResult;
import org.jenetics.util.Factory;

public class HelloWorld {
    // 2.) Definition of the fitness function.
    private static Integer eval(Genotype<BitGene> gt) {
        return gt.getChromosome()

    public static void main(String[] args) {
        // 1.) Define the genotype (factory) suitable
        //     for the problem.
        Factory<Genotype<BitGene>> gtf =
            Genotype.of(BitChromosome.of(10, 0.5));

        // 3.) Create the execution environment.
        Engine<BitGene, Integer> engine = Engine
            .builder(HelloWorld::eval, gtf)

        // 4.) Start the execution (evolution) and
        //     collect the result.
        Genotype<BitGene> result =

        System.out.println("Hello World:\n" + result);

Additional io.jenetics libraries

  • PRNGine: A pseudo-random number generator library for sequential and parallel Monte Carlo simulations. It has been designed to work smoothly with the Jenetics library, but it has no dependency to it. All PRNG implementations of this library extends the Java Random class, which makes it easily usable in other projects.
  • JPX: A Java library for creating, reading and writing GPS data in GPX format. It is a full implementation of version 1.1 of the GPX format. The data classes are completely immutable and allows a functional programming style. They are working also nicely with the Java 8 Stream API. Since it is also possible to calculate the distance between way-points, it is a good fit for the TSP.

Incubation modules

Projects using Jenetics

  • APP4MC: Eclipse APP4MC is a platform for engineering embedded multi- and many-core software systems.



Used software