Results 1 to 7 of 7
  1. #1
    sachinmittal is offline Member
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Question Need help in java program execution...

    Hi all
    I have made a java program( in JAR file) and I need to execute it from a single icon click from other software...can you please tell how to do it..For normal execution i have to go to CMD prompt and write a couple of commands but i want to execute it through 1 single click..
    The method which i though was to direct the icon click to a batch(.bat) file and write the commands in it but its not working properly...do you have any other method
    I am new to java and any help would be appreciated.

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

    Default

    What you mean a single click, respect to Windows. In XP and earlier version to start an application you have to use double click, if you are not enable the single click. In vista you have a nice tool bar on top of the desktop.

    So basically to run/start an application you have to follow one of the above method.

    You can use a single click with such an application. Solution is click-event.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    its not working properly
    What does that mean? Are there error messages? Can you explain? Please post the error messages here.
    What OS are you on? .bat files implies Windows.
    execute it from a single icon click from other software.
    What does that mean? How does software do single icon click?

    When the jre is installed, .jar files should be associated with the java -jar <jarfile> command, so that if you "open"/double click on the jar file the java command is executed which reads the jar file and starts the app as specified in the Main-Class: line.

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

    Default

    I think he's talking about single click within an application, just like a click event on a button. I'm wonder too, other than that we can't use a single click to execute an application.

  5. #5
    sachinmittal is offline Member
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Question Sorry for the confusion guys...

    My question is...
    I have made a java application which is in Jar format....Now jar format by default opens with winrar or winzip...I wanted to know is there any way it can open with JAVA SE program on other user's comp when I distribute this application to other people who dont know java but have JRE installed on their comp.
    1 method is to write" java -jar filename.jar" command in BAT file..and put it in same folder with JAR file but this show command prompt for few seconds which doesn't look good...I want that when I give this program, and user double click it, it should automatically open with JAVA...
    So how to program this..
    P.S: I want to develop it for win 2003,XP and vista
    Thanks

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

    Default

    If you have installed JRE, a jar files are start to execute using that, unless you don't have change the default application.

    So the solution is use of a bat file, as you said. And also there are many ways to do that same thing in Java.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    What OS are you on?
    If Windows, the java installation should have set the default commmandline to java -jar.
    On windows, what do you see when you right click on the jar file? What are the top choices (above the gray line) in the menu?
    What happens if you open a command prompt and enter: java -version

Similar Threads

  1. Replies: 25
    Last Post: 06-28-2008, 05:08 PM
  2. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  3. External Program execution problems
    By vital101 in forum Advanced Java
    Replies: 3
    Last Post: 10-30-2007, 05:17 PM
  4. Replies: 0
    Last Post: 10-04-2007, 09:33 PM
  5. Execution cut
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 06-27-2007, 03:52 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
  •