Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31
  1. #21
    plasticfood is offline Member
    Join Date
    Sep 2010
    Posts
    32
    Rep Power
    0

    Default

    so i should edit the MANIFEST.MF file?

    i'm confused b/c i can't open the manifest.mf file if i'm supposed to at all, and do i edit this stuff while creating my jar file or what?
    Last edited by plasticfood; 12-29-2010 at 05:16 AM.

  2. #22
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    I open it using notepad or any other plain text edit.
    Then when you build you jar file you execute the command
    jar cfm YOUR_JARFILE.jar META-INF/MANIFEST.MF **

    (I missed one parameter earlier)

    So the manifest is just a text file (like .txt) but namned
    .MF instead of .txt
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  3. #23
    plasticfood is offline Member
    Join Date
    Sep 2010
    Posts
    32
    Rep Power
    0

    Default

    the only thing in my manifest file is this:

    Manifest-Version: 1.0
    Main-Class: Program

  4. #24
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    That (the second line) is all you should need if you're are not using
    other .jar files from that .jar file.
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  5. #25
    plasticfood is offline Member
    Join Date
    Sep 2010
    Posts
    32
    Rep Power
    0

    Default

    ok so i erased the first line in the manifest file and saved it.
    then what? do i go to the command prompt and use those commands that you show me?

    also, i extracted the files from the jar file to edit its content, was i supposed to edit the manifest file from within the jar file, or extract them and then edit the file?

  6. #26
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    It would have been possible to modify the file from within the .jar file, if
    you archive manager supports that operation.

    Yes open the command prompt and 'cd' to the folder you extracted the .jar file to, and enter
    jar cfm YOUR_JARFILE.jar META-INF/MANIFEST.MF **
    to rebuild your .jar file and it should be runnable.



    The process of building a .jar file can also be automated using ANT:
    Java Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <project default="default">
      <target name="jar">
        <delete file="YOUR_JAR_FILE.jar"/>
        <jar destfile="YOUR_JAR_FILE.jar"
        basedir="bin" includes="**" manifest="bin/META-INF/MANIFEST.MF"/>
      </target>
      <target name="default" depends="jar" />	
    </project>
    In this example you have your compiled files in a directory “bin”.
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  7. #27
    plasticfood is offline Member
    Join Date
    Sep 2010
    Posts
    32
    Rep Power
    0

    Default

    what exactly is supposed to be in that folder? i have the extracted files and also the jar file in the my folder. is that right? or am i supposed to have only the extracted files in that folder without the original jar file?

    also when i change the directory(C:\Users\Name\Desktop\programFolder) and then use the jar cfm YOUR_JARFILE.jar META-INF/MANIFEST.MF ** command, i got this message:

    "jar is not recognized as an internal or external command....."
    Last edited by plasticfood; 12-30-2010 at 06:43 PM.

  8. #28
    plasticfood is offline Member
    Join Date
    Sep 2010
    Posts
    32
    Rep Power
    0

    Default

    ok this is weird but i've tried running my jar files on another computer and it worked. idk why my desktop can't run it.

    and also, the computer was able to run gui programs but not console apps????

  9. #29
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    Quote Originally Posted by plasticfood View Post
    the computer was able to run gui programs but not console apps????
    In Windows Java has to program for executing java programs: java and javaw.
    java opens a terminal emulator (if not open), and javaw does not open javaw.

    You should always cd to the path with the program.
    Then you do on of the following (add classpaths for additional .jar files):
    - java -cp . FULLY_QUALIFIED_MAIN_CLASS (for .class file with terminal)
    - javaw -cp . FULLY_QUALIFIED_MAIN_CLASS (for .class file without terminal)
    - java -jar JAR_FILE (for .jar file with terminal)
    - javaw -jar JAR_FILE (for .jar file without terminal)


    If you want to make a .jar file runnable be double clicking it like any other program, just can do this steps:

    http://post.dyndns.org/image-00.png
    http://post.dyndns.org/image-01.png
    http://post.dyndns.org/image-02.png
    http://post.dyndns.org/image-03.png
    http://post.dyndns.org/image-04.png
    http://post.dyndns.org/image-05.png
    http://post.dyndns.org/image-06.png
    http://post.dyndns.org/image-07.png
    http://post.dyndns.org/image-08.png
    http://post.dyndns.org/image-09.png
    http://post.dyndns.org/image-10.png
    http://post.dyndns.org/image-11.png
    http://post.dyndns.org/image-12.png
    http://post.dyndns.org/image-13.png (see *)
    http://post.dyndns.org/image-14.png
    http://post.dyndns.org/image-15.png
    http://post.dyndns.org/image-16.png
    http://post.dyndns.org/image-17.png
    http://post.dyndns.org/image-18.png
    http://post.dyndns.org/image-19.png
    http://post.dyndns.org/image-20.png
    http://post.dyndns.org/image-21.png
    http://post.dyndns.org/image-22.png
    http://post.dyndns.org/image-23.png
    http://post.dyndns.org/image-24.png
    http://post.dyndns.org/image-25.png
    http://post.dyndns.org/image-26.png
    http://post.dyndns.org/image-27.png
    http://post.dyndns.org/image-28.png
    http://post.dyndns.org/image-29.png

    If a "key" cannot be created just find the existing one and delete it.

    * This one is incorrect, I do not remember how it should be, but
    test editing the 1 in the end to a 0, -1 and test without it and the , right before it. It could take some time before this change applies, maybe even a login-logout, and it should select the icon for all .jar files.
    Last edited by Hibernate; 01-01-2011 at 04:26 AM. Reason: The forum malformed my post
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  10. #30
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    Quote Originally Posted by plasticfood View Post
    what exactly is supposed to be in that folder? i have the extracted files and also the jar file in the my folder. is that right? or am i supposed to have only the extracted files in that folder without the original jar file?

    also when i change the directory(C:\Users\Name\Desktop\programFolder) and then use the jar cfm YOUR_JARFILE.jar META-INF/MANIFEST.MF ** command, i got this message:

    "jar is not recognized as an internal or external command....."

    It is standard to have a bin/src structure where you have a bin folder for all class files and a src folder for all source files. Other resources should be located in both folder (copied from src to bin when an IDE (e.g. Eclipse, NetBeans) compiles the code). This is however a bit advanced and requires some extra knowledge if you are not using an IDE.
    Otherwise you just have all your files (resources, source code and compiled .class files) in the same folder.

    Move the .jar file so it is not in the same folder as your class files.

    I'll assume you have an JDK installed (otherwise you can't for instance compile code).
    You need to modify a system environment variable:

    http://post.dyndns.org/image2-00.png
    http://post.dyndns.org/image2-01.png
    http://post.dyndns.org/image2-02.png
    http://post.dyndns.org/image2-03.png
    http://post.dyndns.org/image2-04.png
    http://post.dyndns.org/image2-05.png (see *)

    * Here you add path \bin where is the path where Java is installed.
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  11. #31
    plasticfood is offline Member
    Join Date
    Sep 2010
    Posts
    32
    Rep Power
    0

    Default

    thanks for the help! i got it to run!! much appreciate!!!!!!!!!!!!!!!!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 0
    Last Post: 12-21-2010, 04:21 PM
  2. Java Launcher and Applets
    By Bomber_Will in forum Java Applets
    Replies: 2
    Last Post: 01-15-2010, 01:41 AM
  3. JVM launcher?
    By manoj.maniraj in forum Advanced Java
    Replies: 1
    Last Post: 04-07-2009, 12:30 AM
  4. writing a program launcher (or Timer)
    By Farzaneh in forum Threads and Synchronization
    Replies: 3
    Last Post: 02-17-2009, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •