Help with creating a jar file

hi sorry if this is not the place to post the topic but was not sure where to post it.
i have make an application that has some images and a database but i would like to make a "exe" or somthing so that the client dose not have to open an ide and click run. they can just double click on somting. am not sure about how most of you distrbute your apps. can you help me please.
the client will be useing windows 95.
i know that a jar file can do this but i am not sure on how to change the refrences in the code to include the images and every thing. and how would i go about getting it into jar form
thanks nibur

You can create an executable jar.
Note that even if you do this, the user will need to have a JRE installed on their machine for this to run.
Here's how you can make this executable jar:
Replace all code that refers to the filesystem (like if you do "File f = new File("c:\myDirectory\file.txt");") to use resources:
http://java.sun.com/j2se/1.4.2/docs/guide/resources/index.html
Create a manifest file that has a Main-Class: attribute.
Then use the "jar" tool to create the jar:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jar.html
That doc has "see also" links at the bottom that can tell you about executable jars and manifest files.
If you're using an IDE, the IDE probably has a tool to create jars for you. In Eclipse, it's under File -> Export. Check your IDE's docs for details.

Similar Messages

  • Help on creating a jar file

    I created a game and I need help on creating a jar file.
    I know the basics such as having a root folder, a manifest file and what goes in it, etc. And I know some programs like JGrasp can do the jar file for you, but it tells me it cannot find the main class. Does anybody know another program that can do that for me, or can i easily do it manually?
    any help is appreciated

    You can use jar.exe to create jar files.
    Just type jar and hit enter on the console it will give the help message about parameters.
    if you do not really need to put any spesific menifest information. Just zip the files using some zip software and change the extenction to jar. (Thats what I am doing most of the time)

  • Help To Create a Jar File

    hi there
    i wanna create a exe file so i am trying to use jar file.
    I am new at creating jar files, my application has a main file and other java files, i am using other java files in my main file my concern is can i create a jar file including all the files and when i run jar file i want to complie java files, i really appreciate if anyone can help me out creating a jar file to compile and execute java files

    http://java.sun.com/j2se/1.4.2/docs/guide/jar/index.html

  • Help with running java .jar file

    Hi I just installed java with
    # pacman -S jre
    and when i try to run
    java -jar file.jar
    it says command not found. so what do i need to install to be able to run java .jar files through the CLI?

    do, what vintendo says. because it cant find the java in the default paths.

  • Help with classes in .jar file

    Let say, there are additional classes in a .jar file
    How can I add it to my java program so that it can be recognized/used in the java program?
    Need response asap. by Today. TQ

    help...jar... wrote:
    Let say, there are additional classes in a .jar file
    How can I add it to my java program so that it can be recognized/used in the java program?
    Need response asap. by Today. TQClasspath.

  • Help with creating a sql file that will capture any database table changes.

    We are in the process of creating DROP/Create tables, and using exp/imp data into the tables (the data is in flat files).
    Our client is bit curious to work with. They do the alterations to their database (change the layout, change the datatype, drops tables) without our knowing. This has created a hell lot of issues with us.
    Is there a way that we can create a sql script which can capture any table changes on the database, so that when the client trys to execute imp batch file, the sql file should first check to see if any changes are made. If made, then it should stop execution and give an error message.
    Any help/suggestions would be highly appreciable.
    Thanks,

    Just to clarify...
    1. DDL commands are like CREATE, DROP, ALTER. (These are different than DML commands - INSERT, UPDATE, DELETE).
    2. The DDL trigger is created at the database level, not on each table. You only need one DDL trigger.
    3. You can choose the DDL commands for which you want the trigger to fire (probably, you'll want CREATE, DROP, ALTER, at a minimum).
    4. The DDL trigger only fires when one of these DDL commands is run.
    Whether you have 50 tables or 50,000 tables is not significant to performance in this context.
    What's signficant is how often you'll be executing the DDL commands on which the trigger is set to fire and whether the DDL commands execute in acceptable time with the trigger in place.

  • Systemd - help with creating a service file

    Hi, I am trying to make a service file to execute "devmon --no-mount --exec-on-audio abcde". Basicly I want abcde to run when an audio cd is inserted into a headless computer. I have tried some udev rules but had no luck with that.
    I then found udevil and devmon, and it seems to do exectly what I want.
    So Ive made a systemd service file and put it in to /usr/lib/systemd/system
    here is it:
    /usr/lib/systemd/system/abcde-auto.service
    [Unit]
    Description=Virtual Distributed Ethernet
    [Service]
    Type=simple
    ExecStart=/usr/bin/devmon --no-mount --exec-on-audio abcde
    [Install]
    WantedBy=multi-user.target
    I have started this with
    systemctl start abcde-auto.service
    and I see that a devmon process has started with the same arguments I gave in the service file, so all is good.
    But now, I am not too sure about the "Type" in the service file, devmon starts abcde, but:
    systemctl stop abcde-auto.service
    does not stop abcde, only devmon.
    Is there a way to setup the service file so that abcde will end as well as devmon?
    *Edit
    Ive read this http://www.freedesktop.org/software/sys … rvice.html but Im still not too sure. Dont really know what most of it means.
    Last edited by jrussell (2012-10-20 18:09:23)

    I use type 'oneshot' and add an ExecStop= to start and stop scripts.
    Like here is the unit file I use to start and stop arno-iptables-firewall
    [Unit]
    Description=Arno iptables firewall
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStart=/usr/sbin/arno-iptables-firewall start
    ExecStop=/usr/sbin/arno-iptables-firewall stop
    [Install]
    WantedBy=multi-user.target

  • Help with creating jar file and running it ?

    Hey guys,
    I have a program with a package called classes and a sub-package called classes.mainLib.
    I am trying to create a JAR file of the class files in mainLib. There is only one class file in classes and that contains the main method. So this is what i am doing:
    1. create a manifest file with: Main-Class: classes.Cars
    2. from within the mainLib directory (./program_name/classes/mainLib/) i do this:
    jar cvf mainLib.jar manifest ./*.class
    3. Then i move this jar file to ./program_name/lib and change directory to ./program name/
    4. try to do this: java -jar ./lib/mainLib.jar
    But it errors with:
    gary@linuxbox:~/java/cars$ java -jar ./lib/mainLib.jar
    Failed to load Main-Class manifest attribute from
    ./lib/mainLib.jar
    Any ideas why this is happening. the manifest is included in the jar'ing
    Thanks.

    At a glance, it looks like you are placing only the
    class files in the jar and trying to navigate your
    classpath to run it. Instead, you have to place ALL
    the package folders into the jar from the root of
    your package hierarchy and the jar runs anywhere, in
    any folder. The packages are INSIDE the jar.
    also I see cars/classes in a path you describe ...and
    the program seems to wnat classes/Cars ??? Could
    this be an additional issue (or am I missing seeing
    something about your package structure)?Firstly, i believe all my spelling and cases are correct.
    I have the following strcuture:
    Cars.class (contains main) : package classes in ./classes directory
    All other classes : package classes.mainLib in ./classes/mainLib
    I would like to jar ALL files in mainLib but not the class that contains the main method. Is this possible?
    I'm not sure how clear i was earlier, hope this is more understandable.

  • Help having trouble creating a jar file

    I managed to create the jar file but when I try to run it I get the message "Could not find the main class.Program will exit". Here are the comands i used from dos, with the results.
    C:\Documents and Settings\Levybee\My Documents\Greenwich_University\PROJECT\Tac_
    3D>echo Main-Class: Tac3D >manifest.txt
    C:\Documents and Settings\Levybee\My Documents\Greenwich_University\PROJECT\Tac_
    3D>jar -cvmf manifest.txt Tac3D.jar *.class redball.png redball2.png tac3d.png G
    ameOver.png
    added manifest
    adding: Board.class(in = 8497) (out= 4304)(deflated 49%)
    adding: highScores.class(in = 3214) (out= 1864)(deflated 42%)
    adding: highScores2.class(in = 2869) (out= 1674)(deflated 41%)
    adding: PickDragBehavior.class(in = 3931) (out= 2030)(deflated 48%)
    adding: Positions.class(in = 4032) (out= 2181)(deflated 45%)
    adding: Scor.class(in = 1645) (out= 1010)(deflated 38%)
    adding: Scores.class(in = 1384) (out= 866)(deflated 37%)
    adding: SplashScreen.class(in = 1649) (out= 1015)(deflated 38%)
    adding: sScreen.class(in = 1640) (out= 1013)(deflated 38%)
    adding: StartMenu.class(in = 2817) (out= 1619)(deflated 42%)
    adding: Tac3D.class(in = 4606) (out= 2449)(deflated 46%)
    adding: viewhighScores.class(in = 2078) (out= 1235)(deflated 40%)
    adding: ViewScores.class(in = 2646) (out= 1531)(deflated 42%)
    adding: Wrap3D.class(in = 4665) (out= 2437)(deflated 47%)
    adding: redball.png(in = 746) (out= 751)(deflated 0%)
    adding: redball2.png(in = 689) (out= 694)(deflated 0%)
    adding: tac3d.png(in = 5764) (out= 5747)(deflated 0%)
    adding: GameOver.png(in = 3419) (out= 3406)(deflated 0%)help anybody, I got to demostrate it in two days

    You MUST have a line break after the Main-Class part of your manifest.

  • How do you create a jar file with txt and classes?

    Hey, I'm trying to create code to create a jar file with a text file, but I can't figure out how to add the text file. Here is what I have so far:
    try {
                // Name of jar file to write
                String archiveFile = "test.jar";
                Manifest jman = new Manifest();
                try {
                    // Create a manifest from a file
                    //InputStream fis = new FileInputStream("manifestfile");
                    //Manifest manifest = new Manifest(fis);
                    // Construct a string version of a manifest
                    StringBuffer sbuf = new StringBuffer();
                    sbuf.append("Manifest-Version: 1.0\n");
                    sbuf.append("Ant-Version: Apache Ant 1.7.1\n");
                    sbuf.append("Created-By: 1.5.0_19-137 (Apple Inc.)\n");
                    sbuf.append("Main-Class: Main\n");
                    sbuf.append("Class-Path: lib/swing-layout-1.0.3.jar\n");
                    sbuf.append("X-COMMENT: Main-Class will be added automatically by build\n");
                    // Convert the string to a input stream
                    InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
                    // Create the manifest
                    jman = new Manifest(is);
                } catch (IOException e) {
                FileOutputStream stream = new FileOutputStream(archiveFile, true);// archive file is jar file name
                JarOutputStream out = new JarOutputStream(stream, jman);
                out.putNextEntry(new JarEntry("test.txt"));
                out.closeEntry();
                out.close();
            } catch (Exception ex) {
            }It creates the .jar file with the correct manifest but I can't get it to write the test.txt or anything else into the jar file.
    -Gandolf
    Edited by: GanMatt on Jun 18, 2009 8:18 AM
    Edited by: GanMatt on Jun 18, 2009 8:19 AM

    Alright, my question has changed. Here's the code:
    try {
                // Name of jar file to write
                String archiveFile = "test.jar";
                Manifest jman = new Manifest();
                try {
                    // Create a manifest from a file
                    //InputStream fis = new FileInputStream("manifestfile");
                    //Manifest manifest = new Manifest(fis);
                    // Construct a string version of a manifest
                    StringBuffer sbuf = new StringBuffer();
                    sbuf.append("Manifest-Version: 1.0\n");
                    sbuf.append("Ant-Version: Apache Ant 1.7.1\n");
                    sbuf.append("Created-By: 1.5.0_19-137 (Apple Inc.)\n");
                    sbuf.append("Main-Class: Main\n");
                    sbuf.append("Class-Path: lib/swing-layout-1.0.3.jar\n");
                    sbuf.append("X-COMMENT: Main-Class will be added automatically by build\n");
                    // Convert the string to a input stream
                    InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
                    // Create the manifest
                    jman = new Manifest(is);
                } catch (IOException e) {
                FileOutputStream stream = new FileOutputStream(archiveFile, true);// archive file is jar file name
                JarOutputStream out = new JarOutputStream(stream, jman);
                out.putNextEntry(new JarEntry("test.txt"));
                out.write("Hi".getBytes());
                out.flush();
                out.closeEntry();
                out.close();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this,ex.toString(),"BUG!",JOptionPane.INFORMATION_MESSAGE);
            }It creates the jar file with the txt file inside it, but I can't write "Hi" inside of the text file. Any ideas?
    -Gandolf

  • I Can't Create my jar File

    I have a package called voiceexpert which contains three classes: Disease, DiagnosingEngine and Symptoms which is a JavaBean. Symptoms makes use of Disease and DiagnosingEngine objects.
    voiceexpert is stored in the directory: c:\diagapp3
    I compiled Symptoms.java as below:
    c:\diagapp3> javac -d . Symptoms.java
    The class files for Disease.java, DiagnosingEngine.java and Symptoms.java are placed in the directory: voiceexpert.
    I created a Manifest.txt file inside c:\diagapp3 containing the following:
    Main-Class:voiceexpert.voiceexpert.Symptoms
    Name:voiceexpert/Symptoms.class
    Java-Bean:True
    I later created the jar file with the command:
    jar cfm jjj.jar Manifest.txt voiceexpert\*.*
    But, I am having the error message: "*invalid header field*".
    What can I do to remove this error?
    Note: I created the Manifest.txt using utf-8 encoding. My code is to be used in a third-party application and that is why it does not contain a main method.
    The link I was referred to could not help me. I need help please!
    Edited by: Adeyi on Feb 24, 2010 2:26 AM
    Edited by: Adeyi on Feb 24, 2010 2:34 AM

    Adeyi wrote:
    ..I created a Manifest.txt file inside c:\diagapp3 containing the following:
    Main-Class:voiceexpert.voiceexpert.Symptoms
    Note: I created the Manifest.txt using utf-8 encoding. My code is to be used in a third-party application and that is why it does not contain a main method.Why are you specifying a main-class when the API has none?
    The link I was referred to..What link? Just imagine for the moment that the Internet is a big place and we are not psychic.

  • Problems with creation of JAR file

    Hi!
    I can't succeed in creating a JAR file for my application.
    I've followed the guide at http://java.sun.com/docs/books/tutorial/deployment/jar/basicsindex.html
    but apparently im doing something wrong....
    I've tried doing an extra Manifest file aswell as "Setting an Entry Point with the JAR Tool" as written in the guide. noen with success however :(
    I always get the error "Could not find the main class. Program will exit." from the JVM when I try to run my JAR file.
    Structure of my program:
    C:\searchpath\moresearchpath\projectname\src\
    inside src\ there are 3 packages called; "graphic", "client" and "server".
    I want to make a JAR file from the files in the "server" package. The "server" package consists of these following 4 files(and nothing more); "ClientHandler.java", "TestServer.java", "ServerModel.java", "ServerController.java".
    "TestServer.java" is my main class!
    This is an example of a command I've done in order to try to make a JAR file:
    "C:\searchPathToWhereJavaIsInstalled\jdk1.6.0\bin\jar cvfe sgwserver.jar server.TestServer server\*"
    This doesn't generate any error. However when I try to start the .jar I get following message "Could not find the main class. Program will exit."
    I've also tried creating manifest file manually but without success (with UTF-8 encoding and not double .txt ending on file)
    This is how the "Manifest.txt" file has looked when I've tried making one:
    Main-Class: server.TestServer
    I have used Netbeans 5.5 and Java SE 6 for development
    What am I doing wrong? Please help me :(

    If I try to run the one generated from Netbeans I get the following error message: "Failed to load Main-Class manifest attribute from C:\searchpath\moresearchPath\projectName\dist\projectName.jar"
    The thing is I need 2 JAR files, one that contains the files in the "server" package and one that has all other files. The other one is an applet and the files in "server" package are a standalone application.
    How do I get the standalone application's JAR file to work?

  • Create a jar file using the jar tool

    Hello all,
    can somebody help me with this situation:
    I use the following comand
    jar cfm Seti.jar manifest.mf SetiSeti.jar is the name of the file I want to create and Seti is the name of the folder where I have the class files, the manifest file and the Seti.java. The manifest file is also out of this folder (exactly the folder were I use the command on the command line).
    After creating the jar... I try to run it but it gives an error message: "can't find the main class..."
    The content of the manifest file is:
    "Manifest-Version: 1.0
    Main-Class: Seti
    I'd never created a jar file before and have already read all the usefull information here and at sun... I'm very preoccupied with this..
    Can you help?
    Thanks

    RuiAranhaJava wrote:
    How do I do this?
    "And you have to name that package as well when you name the main class in the manifest. "
    But, as I have told the name of the package is SetiNo, you just told us that the name of your class is Set. You never told us about the name of the package.
    Simples question possible: Does your class look something like this:
    package Seti;
    // maybe there are some import statements here, maybe not
    public class Seti {
      // maybe there's something here, maybe not
      public static void main(String[] args) {
        // anything
    }If so, then the fully qualified name of your class is "Seti.Seti" and you need to write that into the Main-Class attribute. (*)
    If there is no package-Statement, then the fully qualified name of your class is simply "Seti" and the Main-Class attribute is correct, but your classes are in the wrong place.
    Edit:
    (*) Please note that package names should generally be all-lowercase, so it should be "seti" instead of "Seti". This helps distinguish it from the simple names of classes, so it's easy to see what you are talking about at a glance: "seti" would be the package, "Seti" the class name.

  • A program that creates a JAR file

    Hello,
    I want my program to generate a JAR file with the content of a folder, by I just don't know how to to this.
    I don't find any help about this and I wonder if it is possible.
    Can someone help me ?
    Does someone know if it is possible to create a jar in a program, and if yes, how to do ?
    Thanks a lot
    Lio

    (I think Lio wanted to create a .jar file in his program, rather than an external program that could create files for him?) The java.util.jar package has classes for creating jar files. They are quite easy to use. You can use this code as a reference:
    http://javaalmanac.com/egs/java.util.zip/CreateZip.html
    (nevermind the fact that the code creates a Zip file rather than a Jar file; the API is so similar you can just replace every occurence of 'zip' with 'jar')

  • Create a jar file

    Hello everybody! :) I really need your help.
    I have Tom.class
    I want to create a jar file.
    I use eclipse, so I created jar file there. I got MarkTven.jar in which:
    Tom.class
    .project
    .classpath
    MATA-INF / MANIFEST.MFin MANIFEST.MF:
    Manifest-Version: 1.0
    Main-Class: Tomclicking at MarkTven.jar I get:
    Invalid or corrupted jar file.Help me please.
    Message was edited by: ghost:))

    I have to say, that although this has nothing to do with me, I'd like to pass some comment. This attitude is prevalent throughout the forums and how can people be expected to gain experience if their efforts will be down-played and you try to make them accountable for their ignorance? It's a contradiction in terms. This is a large forum with more than a lifetimes worth of reading for those of us with a life.
    America70 has given you all the information you require to develop a resolve. I think he/she was depending on you perhaps being aware of a common issue he/she may have overlooked. I would treat that as misplaced respect personally, however, you could have steered him/her towards passing you further detail of his/her issue so that the issue could be resolved. Instead, this query remains, pointlessly, filling up space and uselessly guiding other new leaners no-where.
    You guys may be offering your advice for 'free' but you are also advocates for the language in doing so. Surely you should be making greater efforts to promote the language instead of forcing people to steer clear of attempting to expand their knowledge? It's just an opinion...
    *free - I use this term loosely because the cost to the learner is far from free, the expense being the mentors ego.
    In reference to the above post, America70 had simply made a typo in his/her query to you, not mis-spelt it in his/her implementation; he/she explained that. If he/she is required to add more detail, then politely ask him/her to. America70 also pointed out that he/she had followed the tutorial. It is obvious he/she has mis-read, mis-understood, or badly-impemented something. He/she has obviously overlooked this and is unable to discover the fault. It's not rocket science. If you people can't positively add to this post then what is your use as a helper/teacher?
    Edited by: chewzLife on May 18, 2008 7:50 PM
    Edited by: chewzLife on May 18, 2008 7:51 PM

Maybe you are looking for

  • Best way to set up iPod Touch for kids

    Ok, I know that this has been asked before, but I couldn't find a similar question SINCE Mountain Lion was released, and wasn't sure what iCloud changes have happened since, so here I am asking the question again. I've bought our two oldest girls (ag

  • Running swf from an Executable

    I would like to use swf files as interfaces for my C++ executable files in the Windows environment. I have found a few examples of how to do this on some web sites, but I would like to know more. Specifically, I would like to know about the best way

  • Is it possible to have a cropped clip fill the frame?

    I shot a sequence a sequence of a kid hitting a baseball. He then takes his helmet off and addresses the camera. I would like to "zoom in" on the portion where he addresses the camera. I have cropped this portion, but can I then have it fill the pict

  • Creating external infotypes or external relationships

    Hi, Is it possible to use RH_INSERT_INFTY to maintain external infotypes and relationships? If yes, then anything need to be taken care of. Thanks n regards, Aravind

  • ODA Scan IP validation fails

    We setup all pre-reqs as documented by Oracle for virtualized platform and trying to deploy the configuration but it fails at step 9 of scan ip validation. The error is attached here. From error it seems that it is not getting both scan ips from dns