Results 1 to 8 of 8
  1. #1
    Jonatan10 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Default How to create an executable jar file?

    Ok so I've made a game on Java and I want to create a jar file to run it so I can just have it on my flash drive and use it on any computer that has java installed.
    However I'm having trouble with it. I've googled it and found instruction around that say to type something like this "jar -cf myfile.jar *.class" but where do I type that and is there an easier way to go about creating an executable jar file?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,879
    Rep Power
    8

    Default

    You type that into the command prompt. Google is your friend.

  3. #3
    Jonatan10 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Default

    I did google it. However I didn't understand what to type it into it and I was wondering (hoping) there was an easier solution to it.

  4. #4
    Jonatan10 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Default

    Whenever I try to use that command on the command prompt in the directory of my program I get the following error.
    " 'jar' is not recognized as an internal or external command, operable program or batch file"

  5. #5
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    It is either you set the path in environment variable or locate the bin folder or the javac.exe

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,830
    Rep Power
    19

    Default

    How did you compile your code?
    Because if you're getting that error on your command line then I can't see how javac could have worked.

  7. #7
    Jonatan10 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Default

    I just used jar -cf tictactoe.jar * in the command prompt in the directory of all my class files
    then I got the error

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,879
    Rep Power
    8

    Default

    Quote Originally Posted by Jonatan10 View Post
    I just used jar -cf tictactoe.jar * in the command prompt in the directory of all my class files
    then I got the error
    The question is: how do you compile your .java files into .class files in the first place?

    Because it doesn't make a ton of sense for you to be able to compile but not create a jar- if your system knows where javac is, it should know where jar is (they're in the same place).

Similar Threads

  1. Create Executable Jar file
    By sarwar1234 in forum New To Java
    Replies: 11
    Last Post: 10-28-2010, 12:26 PM
  2. Create Executable Jar file
    By sarwar1234 in forum New To Java
    Replies: 3
    Last Post: 09-27-2010, 05:10 PM
  3. Executable jar file
    By franklyn@bellsouth.net in forum New To Java
    Replies: 12
    Last Post: 08-26-2010, 01:03 PM
  4. How to create java executable file through CMD
    By Riaz Ali in forum New To Java
    Replies: 4
    Last Post: 08-03-2010, 08:20 AM
  5. Create Executable problem
    By castiel in forum New To Java
    Replies: 13
    Last Post: 02-24-2010, 03:04 PM

Posting Permissions

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