Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#9 Add JUL java.util.logging.Handler to the One-Jar

open
nobody
None
5
2012-04-12
2012-04-10
Gerke Forcare
No

I want to be able to add a java.util.logging.Handler to the One-Jar. I thought it could be done like this:
<one-jar destfile="${basedir}/${dist.dir}/one-${ant.project.name}.jar">
<main jar="${basedir}/${dist.jar}/"/>
<lib>
<fileset file="${basedir}/${dist.dir}/lib/*.jar" />
</lib>
<!-- This is where the logging classes are added (they need to be there outside the lib-jars as they need to be available during JVM startup, not later) -->
<fileset dir="${logging-classes-dir}">
<include name="**/*.class"/>
</fileset>
</one-jar>
But it does not seem to work. I keep getting java.lang.ClassNotFoundException

Any directions would be nice, thanks.

Discussion

  • P. Simon Tuffs
    P. Simon Tuffs
    2012-04-10

    One thing to try: create a sub-directory called "tmp" in the place where you launch the one-jar. Set the "Class-Path" manifest attribute in the one-jar to "tmp/". Put your logging class tree under tmp, then run the one-jar. If it works, you need to use the One-Jar-Expand mechanism to do the net-same as above. If it does not work, please create a minimal one-jar that shows the problem (or an Ant build script) and I'll take a look.

     
  • Gerke Forcare
    Gerke Forcare
    2012-04-12

    • summary: A JUL java.util.logging.Handler to the One-Jar --> Add JUL java.util.logging.Handler to the One-Jar
     
  • Gerke Forcare
    Gerke Forcare
    2012-04-12

    I can now confirm that this works. I miss-spelled the classname of the Logging-Handler-class due to a package-name-change.

     
  • Gerke Forcare
    Gerke Forcare
    2012-04-12

    @simontuffs: Thanks for the suggestion. I missed your comment due to my SF-loging being in a state I did not understand. Sorry about that. The problem is solved, as stated in the earlier post.