Results 1 to 12 of 12
  1. #1
    tidus1103 is offline Member
    Join Date
    Mar 2011
    Posts
    9
    Rep Power
    0

    Default Need help with my .jar

    Hello, i just finished writing my project, and i have created a .jar file using my command window. However when i try to run my .jar nothing happens. Im using jdk1.6.0_22.

    So do i need to have any specific code to bring up the command window? my program is completely text based, and does not call JFrame.

  2. #2
    aadem is offline Member
    Join Date
    Mar 2011
    Posts
    22
    Rep Power
    0

    Default few questions

    When i create a jar file i create a manifest file which points to my main class


    In this example consider we are in the directory /home/myjars/ and the file is thisjar.jar
    If you already have the jar, you should be able to run it by typing this:
    java -jar thisjar.jar


    If you need help reconstructing your JAR, or possibly making your own manifest file let me know

  3. #3
    aadem is offline Member
    Join Date
    Mar 2011
    Posts
    22
    Rep Power
    0

    Default by the way

    Even if it did call a JFrame, you can still run the file from the command line, the frame will pop up just fine, and you can even end it by ctrl c (on unix, dunno about windows)

    You can even have a buttons action be to print to the terminal (System.out) as far as i understand it.

  4. #4
    tidus1103 is offline Member
    Join Date
    Mar 2011
    Posts
    9
    Rep Power
    0

    Default

    ok i typed in the java - jar DesktopApplicationRunner.jar andit ran the program, however i when i double click my .jar file it does nothing

  5. #5
    aadem is offline Member
    Join Date
    Mar 2011
    Posts
    22
    Rep Power
    0

    Default hey

    awesome! im glad you got it to run.

    One thing, when you 'double click' a file in your graphical desktop, it doesnt nessecissarily attempt to execute it with the java vm. If your on windows or linux with gnome/kde (unsure on xfce) right click the file an d click open with. you may have to enter the path to the java vm manually the first time if your system didnt associate jar files with it. It also could be that double clicking it actually does do something, you just dont see the output
    because theres no shell for it to talk to :D If you can run it with java -jar its a good file, and thats good news!

  6. #6
    tidus1103 is offline Member
    Join Date
    Mar 2011
    Posts
    9
    Rep Power
    0

    Default

    im on windows 7 btw, i looked around and someone said to us a .bat file with -java -jar DesktopApplicationRunner.jar and it does work, but the command window pops up then closes immediately

  7. #7
    tidus1103 is offline Member
    Join Date
    Mar 2011
    Posts
    9
    Rep Power
    0

    Default

    also i did what you had said about open with and no luck. how do i go about creating a shell?

  8. #8
    aadem is offline Member
    Join Date
    Mar 2011
    Posts
    22
    Rep Power
    0

    Default hmm

    I use linux so im a bit uneducated on the new windows, however i do use windows 7 at work for tech support. When you said the command line comes up and then just closes, im afraid there may be no way around that, for example if you run the ipconfig command from the run box, it will show the ipconfig display information, but immediately close the shell after. The only way i know of to get it to stay is to actually open a shell (command prompt on windows) and type ipconfig, or in your case run the app via java -jar yourjar,jar

    Im sure there has to be some way to make it stay open, looks like we have some researching to do :)

  9. #9
    aadem is offline Member
    Join Date
    Mar 2011
    Posts
    22
    Rep Power
    0

    Default

    add PAUSE at the end of your bat file, the only way ive found aside from adding /k to the run command

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  11. #11
    tidus1103 is offline Member
    Join Date
    Mar 2011
    Posts
    9
    Rep Power
    0

    Default

    lol It worked!!
    thanks a lot for the help. lets hope i go to nationals with this program.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Posting Permissions

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