Results 1 to 4 of 4
  1. #1
    newToJava3 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default jar file running console program

    Hi I have created my netbeans project and created te appriopiate jar file from netbeans. This program is purely console based using "Scanner" for user input and system.out.println

    Whenever I double click the program nothing happens. However when i go to the cmd (I'm using windows) and type: java -jar consolegame.jar
    it works. Is there anyway so that when I double click the jar file it automatically runs the program into console without opening command prompt and loading the jar from there?

    thanks
    Last edited by newToJava3; 12-07-2010 at 12:48 AM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    You could put the command within a batch file and double click the batch file instead of the jar file.

  3. #3
    newToJava3 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    thanks for your reply. would a batch file work on other operating systems such as mac and linux?

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    In general that will depend on the operating system.

    That same command should work on *nix - but the equivalent of a bat file contains a little line at the top to say which shell program should execute the command. And the file itself needs to be made "executable". Google or any *nix web site should describe the process.

Similar Threads

  1. Replies: 4
    Last Post: 04-14-2010, 05:01 AM
  2. Factorial console program
    By er1c550n20 in forum New To Java
    Replies: 6
    Last Post: 04-13-2010, 03:07 PM
  3. Ready To Program, Images in HSA Console?
    By habbah in forum New To Java
    Replies: 2
    Last Post: 01-17-2010, 04:50 AM
  4. Saving Console content to a file
    By puk284 in forum Advanced Java
    Replies: 2
    Last Post: 05-07-2009, 06:58 AM
  5. Replies: 1
    Last Post: 07-24-2007, 03:02 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
  •