How to properly build from source

I am on Gentoo Linux and I am trying to build JabRef from Source.
I’m following the instruction listed in: Installation | JabRef

The command ./gradlew :jabgui:jpackage ends up in a crash (probably because it is meant for Ubuntu and I’m on Gentoo).

I am able to build and run the project with the commands:./gradlew :jabgui:assemble and ./gradlew :jabgui:run

I can’t figure out how build from source this project and obtain a binary executable for my OS.

No - Java is cross-plattform - and not bound to a specific Linux-distribution. Even though, the eco system makes it simpler to provide installers and packags for certain distributions.

Can you please output the crash?

If you are an an x86 system, the ZIP file from https://github.com/JabRef/jabref/actions/runs/21822303500/artifacts/5430843854 should give you a self-extracting runner for the GUI of JabRef. (Created at Enable jbundle for JabKit by koppor · Pull Request #14950 · JabRef/jabref · GitHub)

We are also working on a .jar directly - if you have a Java 25 JRE ready.

Update: Yes, currently jpackage only supports ubuntu on Linux. This is because of some “internal” routing to UI libraries specific for Linux vs. macOS vs. Windows

Please try

./gradlew :jabgui:ShadowJar

This should generate jabgui/build/libs/jabgui-100.0.0-all.jar which you can run with java - jar.

However, on Windows, I get

Exception in thread “JavaFX Application Thread” java.lang.UnsupportedOperationException: Cannot resolve ‘mdi2f-file-tree’
at org.kordamp.ikonli.AbstractIkonResolver.lambda$resolve$0(AbstractIkonResolver.java:62)

I think build-logic\src\main\kotlin\org.jabref.gradle.base.targets.gradle.kts needs to e patched

    target("gentoo") {
        operatingSystem = OperatingSystemFamily.LINUX
        architecture = MachineArchitecture.X86_64
        packageTypes = listOf("app-image")
    }

But I don’t know what to put as target name. No respective documentation found at GitHub - gradlex-org/java-module-packaging: A Gradle plugin to package stand-alone Java applications for multiple operating systems and architectures with 'jpackage'..

Filed upstream issue How to package at Gentoo · Issue #100 · gradlex-org/java-module-packaging · GitHub

@ncvescera In summary, two action points for you

  1. Show the “crash” message
  2. Try out the jabgui-linux-amd64 binary and report back

Well, the result of trying out jbundle will be bad probably

PR adding jbundle:Enable jbundle for JabKit by koppor · Pull Request #14950 · JabRef/jabref · GitHub

It would be great if you could provide us with an exception stack trace of the build failure

I don’t think jbundle is helping us here right now. That is still very much WIP.
Jpackage should work on gentoo as well, despite the naming of the targets for ubuntu. That are just names.

Mabye you are missing some package stuff for creating rpms?

I have some problems reporting the error message: the --stacktrace flag gives me a very long error message and I can’t copy-pase here. Also I can’t upload files :confused:

After build fails I noticed that some files are generated inside jabgui/build/packages.

📁 packages
└── 📁 ubuntu-22.04
    └── 📁 JabRef
        ├── 📁 bin
        │   └── JabRef
        └── 📁 lib

I run bin/JabRef and it works :sparkler:
So the building process fails but generates a working executable (I apologize because I didn’t check before asking)


The command ./gradlew :jabgui:ShadowJar works correctly but when I run the jar file (cd into folder then java -jar jabgui-100.0.0-all.jar) I have the following error:

Error: LinkageError occurred while loading main class org.jabref.Launcher
	java.lang.UnsupportedClassVersionError: org/jabref/Launcher has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 61.0


Running the jabgui-linux-amd64 downloaded from the given link starts the JabRef GUI but immediately spawns some errors.

Hi,

You could probably put the log into https://pastebin.com/

	java.lang.UnsupportedClassVersionError: org/jabref/Launcher has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 61.0

You need JDK 25; your Java version is not the right one

TL;DR:

JDK with 17 or higher:

  1. Install jbundle
  2. jbundle build --input . --gradle-project jabgui --output jabref
  3. ./jabref

If a JDK with Java 25 is available:

  1. ./gradlew :jabgui:shadowJar
  2. java -jar jabgui/build/libs/jabgui-100.0.0-all.jar

Summarizing current state

  1. Wish is to build from source - no binaries.
  2. ./gradlew :jabui:jpackage fails, but produces working binary
  3. ./gradlew :jabui:shadowJar produces a jar, but requires a JDK25
  4. With jbundle, there will be a self-extracting JDK+JabRef bundle - with latest main, you are able to build it using jbundle build --input . --gradle-project jabgui --output jabref
  5. Using gg.cmd enables compiling and running without any Java installation - see How to try out any JabRef pull request | JabRef's Blog for details. However, it was wished to have a binary, not run-from-source.

Regarding 3: The main reason is that the JDK team decided to

  • Move JavaFX out of the JDK to a separate project
  • Be modular and deliver only the necessary packages

Nevertheless, with the jar produced with the patched configuration at Fix ShadowJar config by koppor · Pull Request #15080 · JabRef/jabref · GitHub works. (I currently don’t 100% know why, but it does)