0

I'm getting an error when I try to wrap the Jar to exe through Launch4j.

I have added the library already in the NetBeans IDE and also for the Project but still the error persists.

The Jar is running without any problems but when I try to wrap it, I'm getting always that issue warning:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout

....
....

Caused by: java.lang.ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 17 more

How can I resolve this?

<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="HelaTergo" default="default" basedir=".">
    <description>Builds, tests, and runs the project HelaTergo.</description>
    <import file="nbproject/build-impl.xml"/>
    <!--

    There exist several targets which are by default empty and which can be 
    used for execution of your tasks. These targets are usually executed 
    before and after some main targets. They are: 

      -pre-init:                 called before initialization of project properties
      -post-init:                called after initialization of project properties
      -pre-compile:              called before javac compilation
      -post-compile:             called after javac compilation
      -pre-compile-single:       called before javac compilation of single file
      -post-compile-single:      called after javac compilation of single file
      -pre-compile-test:         called before javac compilation of JUnit tests
      -post-compile-test:        called after javac compilation of JUnit tests
      -pre-compile-test-single:  called before javac compilation of single JUnit test
      -post-compile-test-single: called after javac compilation of single JUunit test
      -pre-jar:                  called before JAR building
      -post-jar:                 called after JAR building
      -post-clean:               called after cleaning build products

    (Targets beginning with '-' are not intended to be called on their own.)

    Example of inserting an obfuscator after compilation could look like this:

        <target name="-post-compile">
            <obfuscate>
                <fileset dir="${build.classes.dir}"/>
            </obfuscate>
        </target>

    For list of available properties check the imported 
    nbproject/build-impl.xml file. 


    Another way to customize the build is by overriding existing main targets.
    The targets of interest are: 

      -init-macrodef-javac:     defines macro for javac compilation
      -init-macrodef-junit:     defines macro for junit execution
      -init-macrodef-debug:     defines macro for class debugging
      -init-macrodef-java:      defines macro for class execution
      -do-jar:                  JAR building
      run:                      execution of project 
      -javadoc-build:           Javadoc generation
      test-report:              JUnit report generation

    An example of overriding the target for project execution could look like this:

        <target name="run" depends="HelaTergo-impl.jar">
            <exec dir="bin" executable="launcher.exe">
                <arg file="${dist.jar}"/>
            </exec>
        </target>

    Notice that the overridden target depends on the jar target and not only on 
    the compile target as the regular run target does. Again, for a list of available 
    properties which you can use, check the target you are overriding in the
    nbproject/build-impl.xml file. 

    -->
</project>

CSS:

Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Class-Path: lib/AbsoluteLayout.jar

HTML:

<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
  <dontWrapJar>false</dontWrapJar>
  <headerType>gui</headerType>
  <jar>C:\Users\ckoca\Documents\NetBeansProjects\HelaTergo\dist\HelaTergo.jar</jar>
  <outfile>C:\Users\ckoca\OneDrive - COMPUTACENTER\Desktop\SerkoBib.exe</outfile>
  <errTitle>Bitte Java vorerst installieren</errTitle>
  <cmdLine></cmdLine>
  <chdir>.</chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
  <supportUrl></supportUrl>
  <stayAlive>false</stayAlive>
  <restartOnCrash>false</restartOnCrash>
  <manifest></manifest>
  <icon>C:\Users\ckoca\Documents\Icons\Icons8-Windows-8-Business-Department.ico</icon>
  <classPath>
    <mainClass>helaTergo.HomeHelaTergo</mainClass>
    <cp>lib/AbsoluteLayout.jar</cp>
  </classPath>
  <jre>
    <path></path>
    <bundledJre64Bit>false</bundledJre64Bit>
    <bundledJreAsFallback>false</bundledJreAsFallback>
    <minVersion>1.6.0</minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>preferJre</jdkPreference>
    <runtimeBits>64/32</runtimeBits>
  </jre>
  <versionInfo>
    <fileVersion>1.0.0.0</fileVersion>
    <txtFileVersion>1.0.0.0</txtFileVersion>
    <fileDescription>Serko Library Software</fileDescription>
    <copyright>Computacenter</copyright>
    <productVersion>1.0.0.0</productVersion>
    <txtProductVersion>1.0.0.0</txtProductVersion>
    <productName>SerkoBib</productName>
    <companyName>Computacenter</companyName>
    <internalName>SerkoBib</internalName>
    <originalFilename>SerkoBib.exe</originalFilename>
    <trademarks></trademarks>
    <language>ENGLISH_US</language>
  </versionInfo>
</launch4jConfig>
halfer
  • 19,824
  • 17
  • 99
  • 186
JavaNoob
  • 1
  • 2
  • It would be helpful if you can post what you have already done - specifically the config file and/or the command line you've used - along with any other relevant information. Right now your question is basically "my launch4j command doesn't work - please help". Please refer to [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – GMc May 10 '19 at 07:18
  • i have just used the build and run option from Netbeans .. the jar is working witouht any problems .. My manifest includes : Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build Class-Path: lib/AbsoluteLayout.jar ... and im using the standart config settings of Netbeans. The Jar is running .. but i cannot convert it to exe – JavaNoob May 10 '19 at 07:29
  • Also i have added the Library to the Project .. – JavaNoob May 10 '19 at 07:31
  • You said: "but i cannot convert it to exe" - however, you did not include the launch4j command line, nor the configuration (xml) file used by launch4j. These are the bits you are having problems with. Therefore, these are the bits people need to see if they are going to have any chance to help you. – GMc May 10 '19 at 07:45
  • I can not see the log. I have never used launch4j myself and thus cannot answer your question. I am trying to help you by prompting you to provide the information others will need to help answer your question. Have you read the [launch4j documentation](http://launch4j.sourceforge.net/docs.html)? It tells you the available command line options and the configuration options - some of them seem to relate to your question. – GMc May 10 '19 at 07:52
  • How can i post or attach the files in here ? This im getting as result from Launch4j: xception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout – JavaNoob May 10 '19 at 07:56
  • My Manifest looks like this: Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build Class-Path: lib/AbsoluteLayout.jar – JavaNoob May 10 '19 at 07:57
  • Edit your question (click the "edit" link just under the question) and add them in the question. This makes it easier for people to see the whole question in one go. The [Markdown Editing](https://stackoverflow.com/editing-help) guide may also be of assistance to you. Do not forget the content of [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). In other words, try to keep the minimum amount of relevant details to the problem you have. Try to make it easy for people to help you. – GMc May 10 '19 at 07:59
  • No, that is the Netbeans project definition file. According to the [link](http://launch4j.sourceforge.net/docs.html) I sent you, launch4j needs an xml configuration file. The launch4j configuration file starts with the XML tag not – GMc May 10 '19 at 08:32
  • Yes. Have you done a clean and build in Netbeans before running launch4j? From the "Run" menu choose "Clean and Build" – GMc May 10 '19 at 09:43
  • Yes, i did that already several times .. still getting the same issue .. – JavaNoob May 10 '19 at 09:47
  • And if you are at a command prompt ready to run the launch4j command, can you see the lib directory? Does it contain AbsoluteLayout.jar? Which directory are you running the launh4j command from? Is it the netbeans project directory? Can you see directories such as build, dist, src and nbproject? If yes, what are the contents of the dist directory? – GMc May 10 '19 at 10:08
  • Yes im using the Netbeans Project Directory. And if i choose the "Custom Classpath" option from Launch4j i can also see the AbsoluteLayout Library ..The contents of the dist directory are the jar itself, the lib directory and a README.TXT – JavaNoob May 10 '19 at 10:13
  • I'm out of ideas - hopefully someone else can help. – GMc May 10 '19 at 10:16
  • There is a discussion forum mentioned on the launch4j web site, did you try there? The forum can be found here: https://sourceforge.net/p/launch4j/discussion/332684/ – GMc May 10 '19 at 10:20
  • Didnt tryed yet .. but im gonna have a look .. thats for your help m8 :) – JavaNoob May 10 '19 at 10:25
  • No worries. Try looking at Grzegorz Kowal's answer on this post: https://sourceforge.net/p/launch4j/discussion/332684/thread/dcc53521/ If that works for you, please answer your question so others can benefit from your research on SO. – GMc May 10 '19 at 10:28
  • I note in the launch4j xml, there is a manifest tag. The contents is empty. It seems a bit strange (because launch4j should pick up the manifest from the main jar) but have you tried supplying the manifest in that field in the GUI (or manually adding it to the CML? – GMc May 11 '19 at 00:03

0 Answers0