Home arrow static arrow Java Programming [Archive] - Executable file inside a jar file!!
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Executable file inside a jar file!!
5 Duke Stars available
This topic has 17 replies on 2 pages.    1 | 2 | Next »

Posts:6
Registered: 6/25/04
Executable file inside a jar file!!  
Jun 25, 2004 5:07 AM



 
Hi,

I have an exe file (start.exe) and more dll files packed in a jar
file.
The exe file needs the dll's. How do i make running the exe file,
without unpacking( extracting/unziping) the jar file?

Does anybody have a clue?

Thank you.
 

Posts:428
Registered: 26.06.00
Re: Executable file inside a jar file!!  
Jun 25, 2004 5:19 AM (reply 1 of 17)



 
I can make it really simple: you can't.

Why would you even want to do that, I can't think of a single good reason?

Cheers
 

Posts:6
Registered: 6/25/04
Re: Executable file inside a jar file!!  
Jun 25, 2004 5:29 AM (reply 2 of 17)



 
As I said the exe and dll's file are packed in a jar file.
My java aplication call this exe file. For a good execution, this exe file needs the dll's files.
I don't wont to unpack manually the jar file to get the dll.
 

Posts:1,385
Registered: 10.06.03
Re: Executable file inside a jar file!!  
Jun 25, 2004 5:42 AM (reply 3 of 17)



 
As salpeter already said, that is not possible.

JAR files are a Java concept. EXE and DLL files are Microsoft Windows executables. Windows doesn't understand EXE and DLL files inside a JAR. As you know, a JAR file is an archive, just like a ZIP file. You can't run Windows programs from a ZIP file without unpacking the ZIP either.

You could unpack the EXE and DLL's in a temporary directory and run it from there.
 

Posts:8,813
Registered: 10/4/00
Re: Executable file inside a jar file!!  
Jun 25, 2004 5:43 AM (reply 4 of 17)



 
One way would be to write some software which essentially turns a jar/zip file into a virtual drive. Once this was done, you could register the dll's and execute the exe.

I really doubt you could do something like this with Java unless you used JNI or wrote your own JVM. C or assembly would be a better choice.
 

Posts:1,385
Registered: 10.06.03
Re: Executable file inside a jar file!!  
Jun 25, 2004 5:45 AM (reply 5 of 17)



 
By the way, you don't need to unpack manually - you can do the unpacking from your Java program. See the classes in the package java.util.jar.
 

Posts:6
Registered: 6/25/04
Re: Executable file inside a jar file!!  
Jun 25, 2004 6:27 AM (reply 6 of 17)



 
Not sure if am i allowed.
This JAR is sent to the client and there are some rules.
Anyway, i got the ideea. Somehow I'll make it work. ;)

Thank you very much for your answers.
 

Posts:428
Registered: 26.06.00
Re: Executable file inside a jar file!!  
Jun 25, 2004 7:27 AM (reply 7 of 17)



 
Have you considered using an "installer" to install your complete "program", nice and easy.
I'm guessing you are only providing support for the windows platform it's pretty easy to create a windows installer, this could also take care of any registry keys, etc.

Just let the installer do it's job (where it's good at) and let it place the exe, dll's, config files and jar in their appropriate directories.

Cheers,

Barre
 

Posts:6
Registered: 6/25/04
Re: Executable file inside a jar file!!  
Jun 25, 2004 8:24 AM (reply 8 of 17)



 
No need to make an installer.
I give to the client the JAR file and an Applet call a class from this JAR file.
By a button click, i have to call the start.exe.
 

Posts:2,275
Registered: 10/18/03
Re: Executable file inside a jar file!!  
Jun 25, 2004 8:30 AM (reply 9 of 17)



 
How does Applet fit into this architecture?

Yours, highly confused with this new addition to your processes,

Sue    ω xxx
 

Posts:31,095
Registered: 4/30/99
Re: Executable file inside a jar file!!  
Jun 25, 2004 8:37 AM (reply 10 of 17)



 
How does Applet fit into this architecture?

You call that an architecture?
 

Posts:21,719
Registered: 98-02-20
Re: Executable file inside a jar file!!  
Jun 25, 2004 8:40 AM (reply 11 of 17)



 
A little annoyance called the sandbox might not allow your applet to run anything on the client with a click of a button. No sense downloading an EXE or DLL to a client where they aren't allowed to run.

%
 

Posts:6
Registered: 6/25/04
Re: Executable file inside a jar file!!  
Jun 25, 2004 8:42 AM (reply 12 of 17)



 
The Applet runs on the clinet server.
So, the jar file will be saved somewhere on their server.
That's why i was asking if is possible to run an exe file inside a jar file. The code that generate this exe is written in another programming language.
 

Posts:20
Registered: 6/17/97
Re: Executable file inside a jar file!!  
Jun 25, 2004 8:49 AM (reply 13 of 17)



 
A proposal:
First :
Create a very simple java CLass to run your exe:

class Launcher{
public static void main(String[] args){
try{
Runtime.getRuntime().exec("myExe.exe");
}catch(Exception e){
e.printStackTrace(System.err);
}
}
}

Second:
add a specific MANIFEST entry into the JAR
MANIFEST.mf:
Main-Class: Launcher

http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html
 

Posts:428
Registered: 26.06.00
Re: Executable file inside a jar file!!  
Jun 29, 2004 4:43 AM (reply 14 of 17)



 
A proposal:
First :
Create a very simple java CLass to run your exe:

class Launcher{
public static void main(String[] args){
try{
Runtime.getRuntime().exec("myExe.exe");
}catch(Exception e){
e.printStackTrace(System.err);
}
}
}

Second:
add a specific MANIFEST entry into the JAR
MANIFEST.mf:
Main-Class: Launcher

http://java.sun.com/docs/books/tutorial/jar/basics/mani
est.html

And exactly HOW does this solve the fact that the libs (native, mind you) needed by the executable are zipped with the JAR.

But anyway, PLEASE, do not go with this "architecture" of an applet, executable. Pick another route, please do. I'm begging you.
There are already so much "architectures" out there which need to be taken out the back and shot, don't add another one.
If your requirements state that you have to do it this way, either pick another language or go for another solution. (PLEASE)
 
This topic has 17 replies on 2 pages.    1 | 2 | Next »