Help with the build.xml ant <path>...

  • James

    James - 2013-02-27

    I think I created a jar via java :
    I tried the build.xml approach and had problems running "ant ? " to compile the build.xml I created.

    the example told me to :

    ant compile
    ant jar
    ant run
    Or shorter with
    ant compile jar run

    whatever that means?
    what does ant compile mean?


    C:\Users\Steves>CD %ANT_HOME%
    C:\Users\Steves\BundlingTools\ant\bin>ANT -version
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jr
    Apache Ant version 1.8.1 compiled on April 30 2010
    C:\Users\Steves\BundlingTools\ant\bin>ant %BUNDLING_TOOLS%\beginnerHello
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jr
    Buildfile: build.xml does not exist!
    Build failed
     Volume in drive C has no label.
     Volume Serial Number is 9869-0873
     Directory of C:\Users\Steves\BundlingTools\beginnerHello
    02/27/2013  06:27 AM    <DIR>          .
    02/27/2013  06:27 AM    <DIR>          ..
    02/26/2013  11:11 PM    <DIR>          build
    02/27/2013  06:27 AM               629 build.xml
    02/26/2013  09:51 PM    <DIR>          src
                   1 File(s)            629 bytes
                   4 Dir(s)  733,645,324,288 bytes free


    created jar with command line:

    this is the contents of :

    Main-Class: oata.HelloWorld


    C:\Program Files\Java\jdk1.7.0_01\bin>jar cvfm %HELLOJAR%\HelloWorld.jar %H
    -c : no such file or directory
    added manifest
    adding: C:/Users/Steves/BundlingTools/beginnerHello/build/classes/(in = 0)
    (out= 0)(stored 0%)
    adding: C:/Users/Steves/BundlingTools/beginnerHello/build/classes/myManifes = 27) (out= 29)(deflated -7%)
    adding: C:/Users/Steves/BundlingTools/beginnerHello/build/classes/oata/(in
    = 0) (out= 0)(stored 0%)
    adding: C:/Users/Steves/BundlingTools/beginnerHello/build/classes/oata/Hell
    oWorld.class(in = 430) (out= 291)(deflated 32%)


    C:\Program Files\Java\jdk1.7.0_01\bin>java -jar %HELLOJAR%\HelloWorld.jar
    Exception in thread "main" java.lang.NullPointerException
            at sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.j
            at sun.launcher.LauncherHelper.checkAndLoadMain(

    C:\Program Files\Java\jdk1.7.0_01\bin>

    C:\Program Files\Java\jdk1.7.0_01\bin>jar tvf %HELLOJAR%\HelloWorld.jar
         0 Wed Feb 27 05:58:58 CST 2013 META-INF/
        68 Wed Feb 27 05:58:58 CST 2013 META-INF/MANIFEST.MF
         0 Wed Feb 27 00:12:26 CST 2013 C:/Users/Steves/BundlingTools/beginnerH
        27 Wed Feb 27 00:12:26 CST 2013 C:/Users/Steves/BundlingTools/beginnerH
         0 Tue Feb 26 22:56:44 CST 2013 C:/Users/Steves/BundlingTools/beginnerH
       430 Tue Feb 26 22:56:44 CST 2013 C:/Users/Steves/BundlingTools/beginnerH

    C:\Program Files\Java\jdk1.7.0_01\bin>

  • P. Simon Tuffs

    P. Simon Tuffs - 2013-02-28

    first: the message about "tools.jar" is significant: you need to be using a JDK not a JRE (download a full Java Developer Kit and use the Java inside it).

    Next I would strongly recommend you try the following steps on your computer.

    1. Download the one-jar-appgen application generator:

    2. Make a temporary directory (e.g. C:\Users\steve\tmp) and cd into it

    3. Execute the one-jar-appgen. This is an application generator, wrapped up in a one-jar, and will create all the directories and files that you need to start with developing a new one-jar application.  It will ask you for a name (keep it simple, no spaces) and a java package name. I recommend "testproject" and "com.testproject".

    4. Now you should see a lot of diagnostics fly by.  Once done, you can "cd testproject" and *this is the cool bit* rebuild the test project by just running "ant".

    5. Finally, run the rebuilt project: "cd build; java -jar testproject.jar"

    This should get you going.  At this point it should be pretty obvious what changes to make to the test project to bootstrap yourself into a full one-jar application.

    Good luck.


  • James

    James - 2013-02-28

    That sounds like what I need to fix thanks a lot I will work on that.
    I showed up today to show my latest attempt to run the helloWorld. So I will
    Display the  results.  Hopefully I can reconfig everything and get going with one jar.
    Thanks again.

    my latest attemp to run the hello example failed again.
    Does anyone have a clue on what is going wrong here?

    C:\Program Files\Java\jdk1.7.0_01\bin>ech %MANIFEST%
    'ech' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Program Files\Java\jdk1.7.0_01\bin>echo %MANIFEST%
    C:\Program Files\Java\jdk1.7.0_01\bin>SET MAIN=%BUNDLING_TOOLS%\%SDK97%\src
    C:\Program Files\Java\jdk1.7.0_01\bin>echo %MAIN%
    C:\Program Files\Java\jdk1.7.0_01\bin>set JARLOC=%BUNDLING_TOOLS%\%SDK97%
    C:\Program Files\Java\jdk1.7.0_01\bin>Echo %JARLOC%%
    C:\Program Files\Java\jdk1.7.0_01\bin>SET JARLOC=%BUNDLING_TOOLS%\%SDK97%
    C:\Program Files\Java\jdk1.7.0_01\bin>ECHO %JARLOC%
    C:\Program Files\Java\jdk1.7.0_01\bin>jar cvfm %JARLOC%\hello.jar %MANIFEST
    added manifest
    C:\Program Files\Java\jdk1.7.0_01\bin>java -jar %JARLOC%\hello.jar
    Error: Could not find or load main class com.simontuffs.onejar.Boot
    C:\Program Files\Java\jdk1.7.0_01\bin>

    created the hello.jar

    C:\Program Files\Java\jdk1.7.0_01\bin>jar tvf %JARLOC%\hello.jar
         0 Thu Feb 28 05:39:42 CST 2013 META-INF/
       304 Thu Feb 28 05:39:42 CST 2013 META-INF/MANIFEST.MF
    C:\Program Files\Java\jdk1.7.0_01\bin>
    C:\Program Files\Java\jdk1.7.0_01\bin>CD %BUNDLING_TOOLS%\%SDK97%
     Volume in drive C has no label.
     Volume Serial Number is 9869-0873
     Directory of C:\Users\Steves\BundlingTools\one-jar-sdk-0.97
    02/28/2013  05:39 AM    <DIR>          .
    02/28/2013  05:39 AM    <DIR>          ..
    02/25/2013  04:01 AM               316 .classpath
    02/25/2013  04:01 AM               387 .project
    02/25/2013  04:01 AM                23 .version
    02/25/2013  04:01 AM             4,649 build.xml
    02/25/2013  04:01 AM    <DIR>          com
    02/25/2013  04:01 AM    <DIR>          doc
    02/28/2013  05:39 AM               448 hello.jar
    02/25/2013  04:01 AM                92
    02/25/2013  04:01 AM    <DIR>          main
    02/25/2013  04:01 AM    <DIR>          META-INF
    02/25/2013  04:01 AM            89,769 one-jar-ant-task-0.97.jar
    02/25/2013  04:01 AM               483 one-jar-ant-task.xml
    01/05/2011  07:33 PM           133,290 one-jar-sdk-0.97.jar
    02/25/2013  04:01 AM             1,046 OneJar.class
    02/25/2013  04:01 AM             1,479 README.txt
    02/25/2013  04:01 AM    <DIR>          src
                  11 File(s)        231,982 bytes
                   7 Dir(s)  733,640,581,120 bytes free
  • James

    James - 2013-02-28

    By the way, do you have some good build.xml stuff form me to practice writing build.xml?


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks