Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

Running an Executable Before Executable JAR

Thread view: 
Jason Cavett - 15 May 2007 20:29 GMT
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.
Eric Sosman - 15 May 2007 20:45 GMT
> 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
[quoted text clipped - 3 lines]
> 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?

Signature

Eric Sosman
esosman@acm-dot-org.invalid

Jason Cavett - 15 May 2007 23:18 GMT
> > 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
[quoted text clipped - 14 lines]
> Eric Sosman
> esos...@acm-dot-org.invalid

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.
Phi - 15 May 2007 21:14 GMT
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
[quoted text clipped - 5 lines]
>
> 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
Sherm Pendley - 15 May 2007 21:17 GMT
> 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--

Signature

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Phi - 15 May 2007 22:41 GMT
Sherm Pendley schrieb:

>> What about telling the OS (eg. windows / linux / macOS) that JAR-files
>> should be executable (using java -jar or javaw) by clicking on them.
[quoted text clipped - 6 lines]
>
> 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
Jason Cavett - 15 May 2007 23:21 GMT
> Jason Cavett schrieb:
>
[quoted text clipped - 35 lines]
>
> 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.
Richard Reynolds - 15 May 2007 23:52 GMT
>> Jason Cavett schrieb:
>>
[quoted text clipped - 46 lines]
> 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?
Sanjay - 16 May 2007 20:12 GMT
> I'm on a Windows system.
>
[quoted text clipped - 6 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.