eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

IvyDE managed libraries not exported

Open
#1,145 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

## Issue description

The classes of IvyDE managed libraries are not exported into a runnable JAR file when a project JRE System Library is JavaSE-17.

## Steps for reproducing the issue

1. Clone [the project](https://github.com/haba713/eclipse-ivyde-export-issue): `git clone git@github.com:haba713/eclipse-ivyde-export-issue.git`
2. Make sure that your Eclipse uses OpenJDK 17 and has IvyDE installed.
3. Import the cloned project into Eclipse workspace.
4. Right-click the class `src/com.example/Main.java` in the project tree and choose Run as → Java Application. See the output: `{"key":"value"}`.
5. Right-click the project and choose Export → Java → Runnable JAR file.
6. Choose the launch configuration created on the step 4 above and choose also Library handling: ◉ Extract required libraries into generated JAR. Click Finish.
7. Try to run the generated JAR file:
```
$ java -jar eclipse-ivyde-export-issue.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
at com.example.Main.main(Main.java:8)
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 1 more
```

The class `org.json.JSONObject` and other JSON classes are not included in the JAR file even though the library is listed in the [Ivy dependencies](https://github.com/haba713/eclipse-ivyde-export-issue/blob/master/ivy.xml).

## Workaround: Use JRE System Library 1.8 instead

Add OpenJDK 8 to Eclipse and change Java Build Path → Libraries → JRE System Library to JavaSE-1.8. After that
the IvyDE managed libraries are included in the runnable JAR file when it's generated again.

See [this commit](https://github.com/haba713/eclipse-ivyde-export-issue/commit/1789bb9e5a583bb1b0baa0481c8ea6e0481ef421).

## JDT or IvyDE issue?
The issue was also reported [here](https://issues.apache.org/jira/browse/IVYDE-394) because I'm not sure if this is a JDT or IvyDE issue.

## Environment

- Eclipse 2022-06 M2 (4.24.0 M2)
- IvyDE 2.2.0.final-201311091524-RELEASE
- OpenJDK 17.0.3+7-Debian-1deb11u1
- Debian GNU/Linux 11 (Bullseye)

Contributor guide

Open the contributing guide

Research direction

Reproduce the export with the linked project using JavaSE-17, then compare it with JavaSE-1.8, where the workaround succeeds. Investigate Eclipse JDT runnable-JAR export and its handling of IvyDE-managed libraries, using IVYDE-394 for context. Done means the generated runnable JAR includes org.json.JSONObject and runs without NoClassDefFoundError.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.