Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 31

Thread: can some one make me a runable jar file?

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default can some one make me a runable jar file?

    i have a project and i am trying to make it to jar files so i can run it from anywhere. problem is that i am trying for 3 weeks and its not working for me. i tried look up online but nothing works.

    if i send you my project can some one plz make it to runable jar file? i cant attach my project here bc it too large. let me know if you can help me out and i can email you the project.

    thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    I use the jar command to make my jar files. Here is a batch file I use for one program:
    @Rem create the IRAComps.jar file:
    set JarName=IRAComps.jar
    %DEV_DRIVE%
    cd %DEV_HOME%\JavaDevelopment\Misc_Projects\IRAComps
    jar -cmf IRAComps.mnf %JarName% *.class *.ini 
    cd %DEV_HOME%\JavaDevelopment
    jar -uf %DEV_HOME%\JavaDevelopment\Misc_Projects\IRAComps\IRAComps.jar NormsTools\IntInputField*.class NormsTools\DoubleInputField*.class NormsTools\ErrDialog*.class NormsTools\MakeEnterDoAction*.class NormsTools\MessageArea*.class NormsTools\MyLabel*.class NormsTools\AppletWrapper*.class NormsTools\AppletHelper*.class
    Echo -------------- Created %JarName% ---------------------
    MORE
    The names enclosed in %s are environment variables
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: can some one make me a runable jar file?

    Have you read the following tutorial?
    Lesson: Packaging Programs in JAR Files (The Java™ Tutorials > Deployment)
    What about the process is the problem? Can you package into a jar? Did you include a manifest file defining the main class? When you run the jar, are there exceptions (hence it may look like it is not running)?

  4. #4
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    i am using eclipse. and my project folder look like this:
    test.jpg
    under image folder i have 3 more folder. and in them i have different images.

    i added a manifest.txt files
    manifest.txt
    main-class: Main

    than i open windows cmd and went under my folder:
    //jar cfvm "jar file" "manifest.txt" "all class file" "all folders"
    C:\Users\dave\My Software\workspace\2D Game 0\src> jar cfvm test.jar Manifest.txt Background.class Enemy_1.class Enemy.class Ground.class Item_0_Background.class Item_1_Fast.class Item_2_Slow.class Item.class Main.class Platform.class Player.class Score.class Shoot.class Sprite_Sheet.class  image music

    than this create a test.jar file. when i click on nothing happen and doesnt open.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    To get any hidden error messages: Open a command prompt window, change to the folder with the jar file and enter:
    java -jar test.jar

    Copy the whole contents of the command prompt window and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    error: could not find or load main class Main

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: can some one make me a runable jar file?

    Unpackage the jar you created using the jar command to see if all the appropriate .class files exist within the jar, especially Main.class which the class loader cannot find based upon post #6

  8. #8
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    i used the command

    jar tvf test.jar

    and i only see the images and music no .class files

    but i used this command:
    jar cfvm ...

    i added all the .class files. not sure why it didnt add them.

  9. #9
    Member
    Join Date
    Jan 2013
    Posts
    34
    My Mood
    Busy
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Re: can some one make me a runable jar file?

    1: Is there not an option in Eclipse to export jars by right-clicking your project, and selecting export, and using the export wizard?

    2. The error you got was a little odd, are you sure you exported the WHOLE project?

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    Is the Main class in a package? If so, the file's location in the jar file must have the package path.
    See the jar command in post#2. Many classes were in the NormsTools package.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    tr.jpg

    here is a pic of my project. its the "2d game 0" project. i have a package but its default and i am not using in any of my class.

    so do i need do enter this command?
    jar cfvm test.jar Manifest.txt default package\Background.class default package\Main.class ...... and so on
    but than it give error no such file "package\Background.class

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    What happens when you use that command?
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    give me error on cmd:

    default : no such file or directory
    package\Background.class : no such file or directory

    also try with no space defaultpackage\Background.class
    still same error no such file..

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    What is the name of the package?
    Is the class file in the jar file saved with the package path folder?

    Here is a tool I wrote years ago for checking the contents of jar files:
    http://normsstuff.zxq.net/NormsJavaT...kClassRefs.jar

    For jar files, select the From jar radio button and then click on the Choose button after the filename field and select the jar file to examine.

    For the Help to work you need this jar file:
    http://normsstuff.zxq.net/NormsJavaT...werWParser.jar
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    #Searching C:\Users\dave\My Software\workspace\2D GAME 0\bin\test1.jar for Background
    Background

    # Found 1 classes.


    it have all of my class. also it have a extra file name "META-INF/MANIFEST.MF" is that the problem?

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    META-INF/MANIFEST.MF
    That's the manifest file. Open it to see. It's needed for the java command to find the starting class.
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    #Searching C:\Users\dave\My Software\workspace\2D GAME 0\bin\test1.jar for image/background/background.png
    image/background/background.png >>>> class NOT found! <<<<

    # Found 1 classes. 1 NOT found.

    its a image and it say no found is that ok? bc its a image and not a class.


    also i enter in cmd:
    start META-INF/MANIFEST.MF
    and it say:
    windows cantnot find 'META-INF/MANIFEST.MF'. make sure you typed the name correctly

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    If the program needs images, you should add the image files to the jar file being sure to put them in the correct folder as used in the get resource method.


    My program only knows about class files. I'm not sure what it does when asked to look for other types of files.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    if i click on "classpath" radio button. and enter "Background.class" in class name than:
    #Searching the classpath for Background
    #user.dir is:     C:\Users\dave\Desktop
    #Using classpath: C:\Users\dave\Desktop\CheckClassRefs.jar
     
    Background   >>>> class NOT found! <<<<
     
    #  Found 1 classes.  1 NOT found.
    ----------------------------------------------------------------------
    "class file" radiobutton and "background.class" in class name: search
    #Using classpath: \
    Background   >>>> class NOT found! <<<<
     
    #  Found 1 classes.  1 NOT found.
    -------------------------------------------------------
    "from jar" radiobutton and "path of test1.jar" in jar filename and "Background.class" in class name: search button
    #Searching C:\Users\dave\My Software\workspace\2D GAME 0\bin\test1.jar for Background
    Background
     
    #  Found 1 classes.
    ---------------------------------------------------------------------------
    "from jar" radiobutton and "path of test1.jar" in jar filename and "Ground.class" in class name: search button
    #Searching C:\Users\dave\My Software\workspace\2D GAME 0\bin\test1.jar for Ground
    Ground
       Main
          Background
          Enemy
             Main
             Player
                Ground
                Sprite_Sheet
                   Main
             Score
                Enemy
                Main
                Player
             Sprite_Sheet
          Enemy_1
             Enemy
             Main
             Sprite_Sheet
          Ground
          Item
             Player
          Item_0_Background
             Item
          Item_1_Fast
             Item
             Score
             Sprite_Sheet
          Item_2_SLOW
             Item
             Score
             Sprite_Sheet
          Platform
             Main
             Player
             Sprite_Sheet
          Player
          Score
          Shoot
             Player
          Sprite_Sheet
       Player
     
    #  Found 14 classes.

  20. #20
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    erre.jpg

    here is a error on cmd

  21. #21
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    Please copy the contents of the command prompt window and paste it here.

    On windows: To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my answer, don't ignore it, ask a question.

  22. #22
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    C:\Users\dave\My Software\workspace\2D GAME 0\bin>jar tf test1.jar
    META-INF/
    META-INF/MANIFEST.MF
    Background.class
    Enemy.class
    Enemy_1.class
    Ground.class
    image/
    image/background/
    image/background/background.png
    image/background/background2.png
    image/ground/
    image/ground/ground.gif
    image/shoot/
    image/shoot/bull2.png
    image/sprite_sheet/
    image/sprite_sheet/enemy1.png
    image/sprite_sheet/item.png
    image/sprite_sheet/platform.png
    image/sprite_sheet/player_sheet.png
    Item.class
    Item_0_Background.class
    Item_1_Fast.class
    Item_2_SLOW.class
    Main.class
    Manifest.txt
    music/
    music/dead.au
    music/jump.au
    music/land.au
    music/running.au
    music/shot_gun.au
    music/suspense.au
    music/theme.au
    Platform.class
    Player.class
    Score.class
    Shoot.class
    Sprite_Sheet.class

    C:\Users\dave\My Software\workspace\2D GAME 0\bin>java -jar test1.jar
    no main manifest attribute, in test1.jar

  23. #23
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    What is in the manifest file?

    Does the last line in the manifest file have an end of line character? Press Enter at the end of line.
    If you don't understand my answer, don't ignore it, ask a question.

  24. #24
    Member
    Join Date
    Oct 2012
    Posts
    133
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Re: can some one make me a runable jar file?

    Manifest.txt
    main-class: Main

    1st line is main-class: Main
    2nd line is enter
    3rd line is enter

  25. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: can some one make me a runable jar file?

    Where did you see an example using lowercase letters?
    My manifest:
    Main-Class: CheckClassRefs

    Have you read: http://docs.oracle.com/javase/tutori...jar/index.html
    Last edited by Norm; March 20th, 2013 at 01:26 PM. Reason: Removed class-path entry
    If you don't understand my answer, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. run jar file inside a jar file?
    By ufrubnuckle in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2013, 06:58 AM
  2. How do you make a console program a .jar in Eclipse?
    By Programmer142 in forum Java Theory & Questions
    Replies: 9
    Last Post: January 13th, 2012, 12:13 AM
  3. [SOLVED] jar file Built(clean and build) perfectly, but not running as jar
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: July 11th, 2011, 11:41 AM
  4. [SOLVED] i cant make a java jar file which can search data from mysql
    By talha07 in forum JDBC & Databases
    Replies: 6
    Last Post: January 20th, 2011, 06:09 AM
  5. got all .java files ready. how to make them into jar?
    By sibbe in forum Java Theory & Questions
    Replies: 22
    Last Post: December 6th, 2010, 07:09 PM