Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse IvyDE managed classes not exported into runnable JAR file
Eclipse IvyDE managed classes not exported into runnable JAR file [message #1852851] Tue, 07 June 2022 21:49 Go to next message
Harri T. is currently offline Harri T.Friend
Messages: 22
Registered: May 2011
Junior Member

The problem
So far, Eclipse has exported IvyDE managed libraries into a runnable JAR file, but I'm not sure why it has stopped working recently. What's wrong? How can I fix the issue?

ivy.xml
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation= "http://ant.apache.org/ivy/schemas/ivy.xsd">
  <info organisation="com.example" module="eclipse-ivyde-export-issue" />
  <dependencies>
    <dependency org="org.json" name="json" rev="20220320"/>
  </dependencies>
</ivy-module>


Steps for reproducing the issue

  1. Clone the project:
    git clone git@github.com:haba713/eclipse-ivyde-export-issue.git

  2. Import the cloned project into Eclipse workspace.
  3. Right-click the class src → com.example → Main.java in the project tree and choose Run as → Java Application. See the output:
    {"key":"value"}

  4. Right-click the project and choose Export → Java → Runnable JAR file.
  5. Choose the launch configuration for the class com.example.Main and Library handling: ◉ Extract required libraries into generated JAR. Click Finish.
  6. 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

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)

(The question was posted also to stackoverflow.com.)

[Updated on: Wed, 08 June 2022 06:11]

Report message to a moderator

Re: Eclipse IvyDE managed classes not exported into runnable JAR file [message #1852854 is a reply to message #1852851] Wed, 08 June 2022 09:21 Go to previous messageGo to next message
Harri T. is currently offline Harri T.Friend
Messages: 22
Registered: May 2011
Junior Member

I tested the same project with Eclipse 2020-06 and OpenJDK 8. JAR export gives a warning "This operation repacks referenced libraries" and IvyDE managed classes are included into the generated JAR file.
Re: Eclipse IvyDE managed classes not exported into runnable JAR file [message #1852855 is a reply to message #1852854] Wed, 08 June 2022 10:30 Go to previous message
Harri T. is currently offline Harri T.Friend
Messages: 22
Registered: May 2011
Junior Member

Workaround is to change the project JRE System Library from 17 to 1.8. See this commit for more information.

Where should this issue be reported?

[Updated on: Wed, 08 June 2022 10:46]

Report message to a moderator

Previous Topic:Exclude a project jar from a built bar file
Next Topic:modular java11 - java17
Goto Forum:
  


Current Time: Thu Mar 28 21:10:06 GMT 2024

Powered by FUDForum. Page generated in 0.02177 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top