Running an Executable Before Executable JAR

Discussion in 'Java' started by Jason Cavett, May 15, 2007.

  1. Jason Cavett

    Jason Cavett Guest

    Is it possible to run an executable prior to the execution of a JAR
    file? Currently, I am doing this via a batch file, but, my customer
    only wants to click on the JAR file and have everything run
    (additional external executable first, then JAR).

    I haven't found anything online, although I'm not sure I'm searching
    for the correct terminology.

    Thanks for any help.
    Jason Cavett, May 15, 2007
    #1
    1. Advertising

  2. Jason Cavett

    Eric Sosman Guest

    Jason Cavett wrote:
    > Is it possible to run an executable prior to the execution of a JAR
    > file? Currently, I am doing this via a batch file, but, my customer
    > only wants to click on the JAR file and have everything run
    > (additional external executable first, then JAR).
    >
    > I haven't found anything online, although I'm not sure I'm searching
    > for the correct terminology.


    How about having the batch file end with

    java -jar ...

    .... and telling the customer to launch the batch file
    (only) instead of the JAR?

    --
    Eric Sosman
    lid
    Eric Sosman, May 15, 2007
    #2
    1. Advertising

  3. Jason Cavett

    Phi Guest

    Jason Cavett schrieb:
    > Is it possible to run an executable prior to the execution of a JAR
    > file? Currently, I am doing this via a batch file, but, my customer
    > only wants to click on the JAR file and have everything run
    > (additional external executable first, then JAR).
    >
    > I haven't found anything online, although I'm not sure I'm searching
    > for the correct terminology.
    >
    > Thanks for any help.
    >


    Hi Jason

    What about telling the OS (eg. windows / linux / macOS) that JAR-files
    should be executable (using java -jar or javaw) by clicking on them.
    On Windows this is the standard, when you install a new JRE.
    Then simply make your manifest pointing to your main class (MANIFEST.MF
    = main-class: MyMain) and calling the external executable
    from within the java-main()-method [using the
    java.lang.Runtime.exec()-method]?
    So actually your JVM is loaded first, starting your main(), then your
    exe is executed and then the rest of your bytecode will be executed.

    But probably I have not understood the "everything" correctly.

    Actually, the way it is stated in your question, I think its logically
    impossible:
    - "the custommer only wants to click on the JAR file ...
    This will make the jar run first!
    Except you have a link on your desktop which is called XYZ.jar and
    actually points to a batch or exe-file ;-)
    - ... and have everyting (whatever this is but including the JAR) run"
    This will run your exe and (", then JAR"), which will call itself
    recursively?
    Does your customer realy mean, that the jar (which he clicked at the
    beginning) has to be executed again?

    Greets phi
    Phi, May 15, 2007
    #3
  4. Phi <> writes:

    > What about telling the OS (eg. windows / linux / macOS) that JAR-files
    > should be executable (using java -jar or javaw) by clicking on them.
    > On Windows this is the standard, when you install a new JRE.


    That's standard on Mac OS X too, although most folks take the extra step
    of bundling the .jar into a .app bundle if they have a lot of Mac users.
    That way they can specify the icon, associate document extensions, etc.
    that you don't get with a generic .jar.

    sherm--

    --
    Web Hosting by West Virginians, for West Virginians: http://wv-www.net
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Sherm Pendley, May 15, 2007
    #4
  5. Jason Cavett

    Phi Guest

    Sherm Pendley schrieb:
    > Phi <> writes:
    >
    >> What about telling the OS (eg. windows / linux / macOS) that JAR-files
    >> should be executable (using java -jar or javaw) by clicking on them.
    >> On Windows this is the standard, when you install a new JRE.

    >
    > That's standard on Mac OS X too, although most folks take the extra step
    > of bundling the .jar into a .app bundle if they have a lot of Mac users.
    > That way they can specify the icon, associate document extensions, etc.
    > that you don't get with a generic .jar.
    >
    > sherm--
    >


    Hi Sherm

    Thanks for competion, when I was a mac user years ago, there was no Java
    around (1985)...

    The issue of bundling a jar into an application seams to be different on
    every platform. I don't think that it is pure a Java issue, but an OS
    issue as well.
    Probably we should know, on which OS our friend Jason wants to execute
    his application. If it's on Gnome (linux), I have some knowledge on
    making "application starters"...

    phi
    Phi, May 15, 2007
    #5
  6. Jason Cavett

    Jason Cavett Guest

    On May 15, 3:45 pm, Eric Sosman <> wrote:
    > Jason Cavett wrote:
    > > Is it possible to run an executable prior to the execution of a JAR
    > > file? Currently, I am doing this via a batch file, but, my customer
    > > only wants to click on the JAR file and have everything run
    > > (additional external executable first, then JAR).

    >
    > > I haven't found anything online, although I'm not sure I'm searching
    > > for the correct terminology.

    >
    > How about having the batch file end with
    >
    > java -jar ...
    >
    > ... and telling the customer to launch the batch file
    > (only) instead of the JAR?
    >
    > --
    > Eric Sosman
    >


    This is the way it was originally done. However, the customer doesn't
    like the batch file window staying open in the background. Haha,
    small problem I know, but it kind of made me curious if it could even
    be done.
    Jason Cavett, May 15, 2007
    #6
  7. Jason Cavett

    Jason Cavett Guest

    On May 15, 4:14 pm, Phi <> wrote:
    > Jason Cavett schrieb:
    >
    > > Is it possible to run an executable prior to the execution of a JAR
    > > file? Currently, I am doing this via a batch file, but, my customer
    > > only wants to click on the JAR file and have everything run
    > > (additional external executable first, then JAR).

    >
    > > I haven't found anything online, although I'm not sure I'm searching
    > > for the correct terminology.

    >
    > > Thanks for any help.

    >
    > Hi Jason
    >
    > What about telling the OS (eg. windows / linux / macOS) that JAR-files
    > should be executable (using java -jar or javaw) by clicking on them.
    > On Windows this is the standard, when you install a new JRE.
    > Then simply make your manifest pointing to your main class (MANIFEST.MF
    > = main-class: MyMain) and calling the external executable
    > from within the java-main()-method [using the
    > java.lang.Runtime.exec()-method]?
    > So actually your JVM is loaded first, starting your main(), then your
    > exe is executed and then the rest of your bytecode will be executed.
    >
    > But probably I have not understood the "everything" correctly.
    >
    > Actually, the way it is stated in your question, I think its logically
    > impossible:
    > - "the custommer only wants to click on the JAR file ...
    > This will make the jar run first!
    > Except you have a link on your desktop which is called XYZ.jar and
    > actually points to a batch or exe-file ;-)
    > - ... and have everyting (whatever this is but including the JAR) run"
    > This will run your exe and (", then JAR"), which will call itself
    > recursively?
    > Does your customer realy mean, that the jar (which he clicked at the
    > beginning) has to be executed again?
    >
    > Greets phi


    I'm on a Windows system.

    And, yeah, they basically don't want to see the batch file window (see
    post above). I *could* do the Runtime.exec (or Process), but the
    location of the executable file is not static, so then I'd have to set
    it up as a config.

    Either way, I also agree that this may not be possible. That's why I
    wanted to ask the brains here and see if anybody knew of any way to
    accomplish the task.
    Jason Cavett, May 15, 2007
    #7
  8. "Jason Cavett" <> wrote in message
    news:...
    > On May 15, 4:14 pm, Phi <> wrote:
    >> Jason Cavett schrieb:
    >>
    >> > Is it possible to run an executable prior to the execution of a JAR
    >> > file? Currently, I am doing this via a batch file, but, my customer
    >> > only wants to click on the JAR file and have everything run
    >> > (additional external executable first, then JAR).

    >>
    >> > I haven't found anything online, although I'm not sure I'm searching
    >> > for the correct terminology.

    >>
    >> > Thanks for any help.

    >>
    >> Hi Jason
    >>
    >> What about telling the OS (eg. windows / linux / macOS) that JAR-files
    >> should be executable (using java -jar or javaw) by clicking on them.
    >> On Windows this is the standard, when you install a new JRE.
    >> Then simply make your manifest pointing to your main class (MANIFEST.MF
    >> = main-class: MyMain) and calling the external executable
    >> from within the java-main()-method [using the
    >> java.lang.Runtime.exec()-method]?
    >> So actually your JVM is loaded first, starting your main(), then your
    >> exe is executed and then the rest of your bytecode will be executed.
    >>
    >> But probably I have not understood the "everything" correctly.
    >>
    >> Actually, the way it is stated in your question, I think its logically
    >> impossible:
    >> - "the custommer only wants to click on the JAR file ...
    >> This will make the jar run first!
    >> Except you have a link on your desktop which is called XYZ.jar and
    >> actually points to a batch or exe-file ;-)
    >> - ... and have everyting (whatever this is but including the JAR) run"
    >> This will run your exe and (", then JAR"), which will call itself
    >> recursively?
    >> Does your customer realy mean, that the jar (which he clicked at the
    >> beginning) has to be executed again?
    >>
    >> Greets phi

    >
    > I'm on a Windows system.
    >
    > And, yeah, they basically don't want to see the batch file window (see
    > post above). I *could* do the Runtime.exec (or Process), but the
    > location of the executable file is not static, so then I'd have to set
    > it up as a config.
    >
    > Either way, I also agree that this may not be possible. That's why I
    > wanted to ask the brains here and see if anybody knew of any way to
    > accomplish the task.
    >

    would the windows "start" command do your job?

    I vaguely remember using it, think it starts a process for you and
    disconnects it from the cmd window letting it close so maybe you could use
    it at the end of your batch file to start up the jvm using javaw?
    Richard Reynolds, May 15, 2007
    #8
  9. Jason Cavett

    Sanjay Guest


    > I'm on a Windows system.
    >
    > And, yeah, they basically don't want to see the batch file window (see
    > post above). I *could* do the Runtime.exec (or Process), but the
    > location of the executable file is not static, so then I'd have to set
    > it up as a config.
    >
    > Either way, I also agree that this may not be possible. That's why I
    > wanted to ask the brains here and see if anybody knew of any way to
    > accomplish the task.
    >



    I haven't done it, so I am not sure it will work. Can you create a small
    VB or C# program that runs your jar and then compile it as executable?
    Thais way even if you have to open a command prompt you can hide it.
    Sanjay, May 16, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    567
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,718
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,752
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    657
    Arnold Peters
    Jan 5, 2005
  5. Replies:
    15
    Views:
    487
    Dave Thompson
    Aug 21, 2006
Loading...

Share This Page