Thread: Java: Packaging Self-running Jar

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    Java: Packaging Self-running Jar

    I'm trying to package my Java app into self-running jar file. But it always says "Could not find the main class." If you could take a look of the process and tell me what I did wrong, that would be greatly appreciated.

    Files structure:
    Code:
    manifest.mf
    TaskManager/
        data.xml
        bin/
            TaskManagerFrame.class
            Task.class
            Organizer.class
        doc/
        images/
            delete-task.png
            new-task.png
            print.png
        src/
            TaskManagerFrame.java
            Task.java
            Organizer.java
    The main method is in TaskManagerFrame, and the content of manifest.mf is the following.
    Code:
    Manifest-Version: 1.0
    Class-Path: TaskManager/bin/
    Main-Class: TaskManager/bin/TaskManagerFrame
    The command to produce the jar file follows.
    Code:
    jar cmvf manifest.mf taskmanager.jar TaskManager
    The jar file is produced, but when double-clicked, it says "Could not find the main class."
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    shouldn't be
    Main-Class: TaskManager.bin.TaskManagerFrame
    like a import directive ??
    but TaskManager.bin are interpreted as packages so you can try also
    Main-Class: TaskManagerFrame

    In any case, first of all the manifest.mf file must be inside meta-inf/ directory

    extra: a jar file is a zip file
    And I don't work with java for some long time...
    Last edited by xErath; 06-29-2005 at 10:37 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  2. Multiple Java files for one Java project
    By doubleanti in forum Windows Programming
    Replies: 2
    Last Post: 11-22-2004, 02:06 AM
  3. Tasty Java
    By The Brain in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 11-12-2004, 11:44 AM
  4. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  5. Java the backbone of web-industry ?
    By Zeeshan in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-10-2002, 10:35 PM