One jar did not work for me

James
2012-11-12
2013-05-23
  • James
    James
    2012-11-12

    Hello. I am trying to jar a new project.
    I followed the diredtions in the quick start and it does not work.
    I double clicked the jar file that "One Jar" created
    nothing happens.

    The quick start told me to do the following:
    If I use :java -jar -XMX256m : it says :

    C:\Program Files\Java\jdk1.7.0_01\bin>java -jar -Xmx256m C:\Users\Steves\Documen
    ts\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\guideOneJar.jar
    Error: Could not find or load main class com.simontuffs.onejar.Boot
    C:\Program Files\Java\jdk1.7.0_01\bin>
    
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: One-Jar 0.97 Ant taskdef
    One-Jar-Expand: lib/Beans Binding-beansbinding-1.2.1.jar lib/TopLink Esssentials-toplink-esentials.jar lib/TopLink Essentials-toplink-essentials-agent.jar lib/Absolute Layout-AbsoluteLayout.jar lib/Swing Layout Extensions-swing-layout-1.0.4.jar lib/Swing Application Framework-appframework-1.0.3.jar lib/Swing Application Framework-swing-worker-1.1.jar 
    One-Jar-Expand-Dir: ./one-jar-sdk-0.97
    One-Jar-Confirm-Expand: true
    One-Jar-Show-Expand: true
    Main-Class: com.simontuffs.onejar.Boot
    One-Jar-Main-Class: build.classes.view.Main
    
    C:\Program Files\Java\jdk1.7.0_01\bin>jar -cvfm C:\Users\Steves\Documents\ceyesu
    mma\java_cache\my_projects\netbeans\guide\target_guide\guideOneJar.jar  C:\Users
    \Steves\Documents\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\B
    undlingTools\META-INF\MANIFEST.MF
    added manifest
    C:\Program Files\Java\jdk1.7.0_01\bin>
    

    Why can't one jar find its main class?

     
  • P. Simon Tuffs
    P. Simon Tuffs
    2012-11-13

    Try putting java on your path and running the jar from a path that does not contain a space.  Windows can be picky about spaces in the path, and it looks like your working directory is C:\Program Files\Java\jdk1.7.0_01\bin>

    Simon.

     
  • James
    James
    2012-11-14

    C:\Program Files\Java\jdk1.7.0_01\bin>jar -cvfm C:\Users\Steves\Documents\ceyesu
    mma\java_cache\my_projects\netbeans\guide\target_guide\guideOneJar.jar  C:\Users
    \Steves\Documents\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\B
    undlingTools\META-INF\MANIFEST.MF
    added manifest
    C:\Program Files\Java\jdk1.7.0_01\bin>
    

    Why can't one jar find its main class?

    Moving the JVM did not seem to matter.  I have used ONE JAR successfully on a small
    app. 1 mb or so. this one is 60 and the other one that failed was over 100mb.

    My projects use the properties from the Netbeans IDE *.properties and I pragmatically load
    a properties file that is used to load XML properties .  This app may have
    some derby code in it but it is not using a database. I am not sure why I loaded
    some of the Swing.*.jar's It has been working with them for years now.

    The instructions for command line one jar procedure said to unjar the one-jar-appgen-0.97.jar . I have
    no idea what is meant by this. I did uppack200 the jar and got some of the files.
    however when I changed the ext on the one-jar-appgen-0.97.jar to one-jar-appgen-0.97.zip and
    extracted the files I found all the dir's involved in the command line approach.

    JAVA is telling me it can not:

    Error: Could not find or load main class com.simontuffs.onejar.Boot

    it (the com.simontuffs.onejar.Boot dir)is sitting in a folder with the META-INF folder dir and my app is along side those. Hence the paths in the MANIFEST should be pointing right to them. Shouldn't they? They are all in the same BundlingTools dir (or root).

    I have my apps jar created by Netbeans in the BundlingTools/main

    I know that some how the ClassLoader needs to load all the classes as they are needed
    or whatever.  I -cfvm your program to create the classes with there dependencies in BundlingTools/lib
    That seems like a good time to use your Main-Class: com.simontuffs.onejar.Boot .

      So, when I java -jar and try to execute the one jar your program created (guideOneJar.jar) for me via the command line.
    Why would it be trying to load your Main-Class: com.simontuffs.onejar.Boot?

    C:\Program Files\Java\jdk1.7.0_01\bin>java -jar -Xmx256m C:\Users\Steves\Documen
    ts\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\guideOneJar.jar
    Error: Could not find or load main class com.simontuffs.onejar.Boot
    I am not sure of the order of operation but I do know
    that my app contains the jar's that I have in the lib/ And the app jars are listed
    correctly in the MANIFEST. All the spelling in all 3 locations are exact.
    The problem must be that the com.simontuffs.onejar.Boot class is in error because if
    it is designed to recursively load classes and there resources then I have done
    everything I can do.
    the .exe produced by one jar does not respond to the double click ?
    Do you know why the error states : 
    C:\Program Files\Java\jdk1.7.0_01\bin>java -jar -Xmx256m C:\Users\Steves\Documen
    ts\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\guideOneJar.jar
    Error: Could not find or load main class com.simontuffs.onejar.Boot
    C:\Program Files\Java\jdk1.7.0_01\bin>
    
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: One-Jar 0.97 Ant taskdef
    One-Jar-Expand:lib/AbsoluteLayout.jar lib/appframework-1.0.3.jar lib/derby.jar lib/dom4j-1.4.jar lib/dsn.jar lib/imap.jar lib/jcalendar.jar lib/joda-time-1.6.2.jar lib/joda-time-1.6.2-javadoc.jar lib/joda-time-1.6.2-sources.jar lib/joda-time-1.6.jar lib/junit-3.8.2.jar lib/junit-4.5-src.jar lib/mail.jar lib/mailapi.jar lib/pop3.jar lib/smtp.jar lib/swing-worker-1.1.jar
    One-Jar-Expand-Dir: ./one-jar-sdk-0.97
    One-Jar-Confirm-Expand: true
    One-Jar-Show-Expand: true
    Main-Class: com.simontuffs.onejar.Boot
    One-Jar-Main-Class: build.classes.view.Main
    

    *.jar files in the lib/  are in exact order and exact spelling. Who knows how they are
    loaded by the class loader but the app runs so these should do the same if
    one jar and the classloader are playing well together.

    lib/AbsoluteLayout.jar lib/appframework-1.0.3.jar lib/derby.jar lib/dom4j-1.4.jar lib/dsn.jar lib/imap.jar lib/jcalendar.jar lib/joda-time-1.6.2.jar lib/joda-time-1.6.2-javadoc.jar lib/joda-time-1.6.2-sources.jar lib/joda-time-1.6.jar lib/junit-3.8.2.jar lib/mail.jar lib/mailapi.jar lib/pop3.jar lib/smtp.jar lib/swing-worker-1.1.jar lib/junit-4.5-src.jar
    

    You have been bearing with my comedy of errors for a while now. So Thanks again for your time.

    But wait one more stupid question:

    One-Jar-Main-Class: com.simontuffs.onejar.sdk.Install
    One-Jar-Expand-Dir: ./one-jar-sdk-0.97

    these two entries into the MANIFEST that is delivered.
    I do not address them at all and have no idea if the command line approach
    needs them.

    thanks

    jar -cvfm C:\Users\Steves\Documents\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\guideOneJar.jar  C:\Users\Steves\Documents\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\BundlingTools\META-INF\MANIFEST.MF

    java -jar -Xmx256m C:\Users\Steves\Documents\ceyesumma\java_cache\my_projects\netbeans\guide\target_guide\guideOneJar.jar

    lib/AbsoluteLayout.jar lib/appframework-1.0.3.jar lib/derby.jar lib/dom4j-1.4.jar lib/dsn.jar lib/imap.jar lib/jcalendar.jar lib/joda-time-1.6.2.jar lib/joda-time-1.6.2-javadoc.jar lib/joda-time-1.6.2-sources.jar lib/joda-time-1.6.jar lib/junit-3.8.2.jar lib/mail.jar lib/mailapi.jar lib/pop3.jar lib/smtp.jar lib/swing-worker-1.1.jar lib/junit-4.5-src.jar

     
  • P. Simon Tuffs
    P. Simon Tuffs
    2012-11-21

    There may be a simple solution to your problems.  Instead of manually building the jar file in the Quick Start - "Command Line Approach", try installing Ant and using the "Application Generator Approach". I have pasted the relevant sections from the guide (http://one-jar.sourceforge.net/index.php?page=getting-started&file=quickstart):.

    You can download and install Ant by following the instructions here:

    http://ant.apache.org/bindownload.cgi

    There are many fewer steps in rebuilding an application this way, hopefully this will work for you.  Once you can rebuild and run this test-one-jar.jar you should be on track to make changes to add in your own code (add libs, change main, etc). After each step I recommend you rebuild and test to make sure everything is working.

    Hope this helps.

    Simon.

    Application Generator Approach

    This approach provides you with a complete Eclipse/Ant application directory, which you can use as a starting point for your own One-JAR application. The application generator is driven by a template built into the one-jar-appgen.jar file (see one-jar-appgen)
    Download one-jar-appgen-0.97.jar
    Generate application, build, and run it.
    $ java -jar one-jar-appgen-0.97.jar

    Enter project path (project name is last segment): c:/tmp/test-one-jar
    Enter java package name: com.example.onejar
    $ cd c:/tmp/test-one-jar
    $ ant
    $ cd build
    $ java -jar test-one-jar.jar
    test_one_jar main entry point, args=
    test_one_jar main is running
    test_one_jar OK.

     
  • James
    James
    2012-11-26

    I have tried that way on other attempts and the project generator did work but I thought it needed Eclipse or somthing.
    Could it be that the size of the application is effecting one jar performance here?
    Thanks I will try the Application Genarator again.

     
  • James
    James
    2012-11-29

    if I sent the app to you would you have time to try to get it to run in One Jar ?
    Thanks

     
  • P. Simon Tuffs
    P. Simon Tuffs
    2012-11-29

    I'd be prepared to give it a shot.  If you can get me the version built using the ant task (i.e. without Netbeans which I believe is your default environment) I'll try to take a look over the weekend.  Hopefully something obvious will pop out.

    Ideally send both the source code/library tree and the built binary.  If you could zip it up, and then unzip and qualify as buildable before sending that would give me the best chance of success.

    Simon.

     
  • James
    James
    2013-02-25

    Right now I am focusing on learning as much as I can to use : commands : ant : one jar : build.xml : I have just started using
    reading and writing xml and the XML db. I will keep struggling over the learning curve and use my three "unjared" programs as a driving incentive. I broused over your "how one jar works".doc and realized I need to learn this. Is there a good way to approach all these
    topics?
    thanks again