Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Running an Executable Before Executable JAR

Reply
Thread Tools

Running an Executable Before Executable JAR

 
 
Jason Cavett
Guest
Posts: n/a
 
      05-15-2007
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.

 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      05-15-2007
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
http://www.velocityreviews.com/forums/(E-Mail Removed)lid
 
Reply With Quote
 
 
 
 
Phi
Guest
Posts: n/a
 
      05-15-2007
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
 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      05-15-2007
Phi <(E-Mail Removed)> 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
 
Reply With Quote
 
Phi
Guest
Posts: n/a
 
      05-15-2007
Sherm Pendley schrieb:
> Phi <(E-Mail Removed)> 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

 
Reply With Quote
 
Jason Cavett
Guest
Posts: n/a
 
      05-15-2007
On May 15, 3:45 pm, Eric Sosman <(E-Mail Removed)> 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
> (E-Mail Removed)


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.

 
Reply With Quote
 
Jason Cavett
Guest
Posts: n/a
 
      05-15-2007
On May 15, 4:14 pm, Phi <(E-Mail Removed)> 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.

 
Reply With Quote
 
Richard Reynolds
Guest
Posts: n/a
 
      05-15-2007

"Jason Cavett" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> On May 15, 4:14 pm, Phi <(E-Mail Removed)> 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?


 
Reply With Quote
 
Sanjay
Guest
Posts: n/a
 
      05-16-2007

> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I run a c executable in pwd ,while the executable is in some other directory vishsid3@gmail.com C Programming 15 08-21-2006 06:04 AM
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM



Advertisments