package exe in a jar

K

Krisp

Hi,

I am executing an exe through my java program.
the path is hardcoded in java.

Now i want to package my exe in a jar file.
i have been successful in that as well.

But am stuck as i have the path name hardcoded in the java file.
so am not able to execute my jar as a stand alone program.

Any hints for packaging such jar i.e having an exe inside and able to
run it as a stand alone program?

Thanks,
Krisp
 
A

Arne Vajhøj

Krisp said:
I am executing an exe through my java program.
the path is hardcoded in java.

Now i want to package my exe in a jar file.
i have been successful in that as well.

But am stuck as i have the path name hardcoded in the java file.
so am not able to execute my jar as a stand alone program.

Any hints for packaging such jar i.e having an exe inside and able to
run it as a stand alone program?

Not possible.

EXE's are loaded bu the operating system and the operating system
does not know about jar files (at least not the common ones).

Arne
 
K

Krisp

Thanks Arne,

i just searched for "exe inside jar" in the archives of the group.

found out that extracting the exe in a temp directory
and then running the exe might be one solution to such senario.

But just hopped there could be a better solution.

Thanks,
Krisp
 
A

Arne Vajhøj

Krisp said:
i just searched for "exe inside jar" in the archives of the group.

found out that extracting the exe in a temp directory
and then running the exe might be one solution to such senario.

That is one workaround.
But just hopped there could be a better solution.

Nope.

Why not just have the exe in the same dir as the jar ?

Arne
 
B

blue indigo

Hi,

I am executing an exe through my java program.
the path is hardcoded in java.

Now i want to package my exe in a jar file.
i have been successful in that as well.

But am stuck as i have the path name hardcoded in the java file.
so am not able to execute my jar as a stand alone program.

Any hints for packaging such jar i.e having an exe inside and able to
run it as a stand alone program?

Does the functionality in the exe have to be in a stand-alone program? If
not, and if it's your code, you might want to turn it into a DLL and call
it from JNI, or even reimplement the functionality in Java.
 
B

blueparty

Arne said:
That is one workaround.


Nope.

Why not just have the exe in the same dir as the jar ?

Arne

It is possible to store .EXE in a jar file, but you will not be able to
determine the exact path, in order to execute it. As previous poster
said, you can access it as a data file, using 'getResourceAsStream' or
some similar method and copy it to some known path. Then you can
execeute it.

In fact, in the spirit of Java is to keep anything native as loosely
tied ass possible. That means Java code should deal with an abstract
executable that takes particular parameters and returns some code. Exact
path should be passed as a property (-D or Properties file) or something
like that.

B
 
R

Roedy Green

I am executing an exe through my java program.
the path is hardcoded in java.

Now i want to package my exe in a jar file.
i have been successful in that as well.

But am stuck as i have the path name hardcoded in the java file.
so am not able to execute my jar as a stand alone program.

Any hints for packaging such jar i.e having an exe inside and able to
run it as a stand alone program?

What you really want to do is package a DLL in your jar, various
versions of it for different platforms, and have JWS sort it all out.

Otherwise you are going to have to treat your exe like a resource,
extract it, write it to disk and exec it.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Learning is not compulsory... neither is survival."
~ Dr. W. (William) Edwards Deming (born: 1900-10-14 died: 1993-12-20 at age: 93))
 
A

Arne Vajhøj

blueparty said:
It is possible to store .EXE in a jar file, but you will not be able to
determine the exact path, in order to execute it. As previous poster
said, you can access it as a data file, using 'getResourceAsStream' or
some similar method and copy it to some known path. Then you can
execeute it.

But if it has to be extracted anyway, then I think it would would be
easier just to have it as external file from the beginning.

Installers and simple unzip can fix the multiple file distribution
problem.

Arne
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top