This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
[ JDK VERSION : 1.7.0_45 ] STEPS: * Java project without Main class set. * Add dependent project via Libraries->Add JAR/Folder i.e dist/Other.jar. * Build project. ACTUAL: The dependent jar is copied to dist/lib/Other.jar. OK EXPECTED: Additionally /lib/Other.jar should be added to manifest of dist/This.jar
Works for me. 1) Create TestLib project 2) Create TestApp project 3) Build TestLib 4) Add LestLib/dist/TestLib.jar as JAR/Folder. 5) Build TestApp Here is the TestApp.jar manifest content: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.9.4 Created-By: 1.8.0-b132 (Oracle Corporation) Class-Path: lib/TestLib.jar X-COMMENT: Main-Class will be added automatically by build Main-Class: testapp.TestApp There is CP attribute with lib/TestLib.jar I will also attach the test projects.
Created attachment 148375 [details] Test projects
Created attachment 148396 [details] 3 test projects Try this one. STEPS: Run TestApp.jar ACTUAL: Exception in thread "main" java.lang.NoClassDefFoundError: org/me/lib/Util at org.me.lib.Util2.sub(Util2.java:14) at testapp.TestApp.main(TestApp.java:20) Caused by: java.lang.ClassNotFoundException: org.me.lib.Util EXPECTED: The dependent lib/TestLib.jar should be added to manifest of TestLib2/dist/TestLib2.jar
(In reply to Tomas Zezula from comment #1) > 5) Build TestApp > Here is the TestApp.jar manifest content I) Your TestApp does not fulfil the condition of step 1: * Java project without Main class set. II) Additionally IMO when for a project, here TestApp.jar, there is another dependence in a dependent jar, here TestLib2.jar dependent on TestLib.jar: - Add TestLib.jar + TestLib2.jar to TestApp/dist/. - Add lib/TestLib.jar + lib/TestLib2.jar to classpath of TestApp.jar/MF Could this be covered by this bug or should I open a separate jar? However, because of the missing condition at this moment it is unclear, if II) is already implemented.
I've tested the attached 3 projects. When built, the TestApp.jar MANIFEST-MF contain is: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.9.4 Created-By: 1.8.0-b132 (Oracle Corporation) Class-Path: lib/TestLib2.jar X-COMMENT: Main-Class will be added automatically by build Main-Class: testapp.TestApp It contains Class-Path: lib/TestLib2.jar which is correct. It does not contain TestLib.jar as there no runtime dependency on it, the Ant projects unlike Maven have no transitive dependency. You need to add TestLib at least to Runtime ClassPath. If you do it and rebuilt the TestApp the TestApp.jar MANIFEST-MF contain is: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.9.4 Created-By: 1.8.0-b132 (Oracle Corporation) Class-Path: lib/TestLib2.jar lib/TestLib.jar X-COMMENT: Main-Class will be added automatically by build Main-Class: testapp.TestApp Here is an enhancement for automatic adding of transitive libs to runtime classpath: https://netbeans.org/bugzilla/show_bug.cgi?id=47507 Also when you create the project as a library project it has by default disabled copying of dependencies (as the library is a dependency itself). You can enable it in the Project Properties/Packaging/Copy Dependent Libraries.
(In reply to Tomas Zezula from comment #5) > Here is an enhancement for automatic adding of transitive libs to runtime > classpath: > https://netbeans.org/bugzilla/show_bug.cgi?id=47507 Thanks for the pointer. > Also when you create the project as a library project it has by default > disabled copying of dependencies (as the library is a dependency itself). > You can enable it in the Project Properties/Packaging/Copy Dependent > Libraries. Aha, the dependency classpath is only set, if copying of dependencies is enabled, and the latter is not enabled by default for libraries, but for applications. So thanks for the explanation and sorry for the noise.
>Aha, the dependency classpath is only set, if copying of dependencies is enabled, and >the latter is not enabled by default for libraries, but for applications. Yes. >So thanks for the explanation and sorry for the noise. No problem. Better noise then forgotten bug.