Link to home
Start Free TrialLog in
Avatar of tommyboy2214
tommyboy2214

asked on

JSP create self extracting exe to run on Windows but

Good day all,
I am looking to develop a solution that acts kind of like the windows update page

I have already developed the front end which is a jsp that has a list of files to download with
checkbox's beside them. When the form with these parameters is submitted, i want to have a program that sits on the server and creates a self-extracting exe with the selected files in it. Also, i would prefer this exe to automatically install files into a specified directory(C:\Cognos\Reports) and overwrite existing files without prompting user if possible. The problem is that our web server is Unix(Solaris) and files need to be downloaded to Windows Client computers. Therefore i need a program that is compatible with Unix and creates .exe for Windows2000 clients(250 clients). I looked into a couple of software packages like PKZIP and RAR(not compatible with Solaris) but none could do everything i needed. I am open to any solution that can get this job done, ie(purchasing software, servlet, package, etc..)

Please help as i have been trying to find solution for two weeks now!! :-)

thanx a million

Tom

Avatar of Mick Barry
Mick Barry
Flag of Australia image

Why does it need to be an exe, why not just use a batch file?
Or a signed Java applet.
Avatar of tommyboy2214
tommyboy2214

ASKER

It needs to be an exe so when the user downloads to computer it automatically puts files into a specific directory. Thats the only way i could think of doing it.
I looked into editing a batch file on the server and then sending it to the computer. but i wasnt sure if when a computer downloaded a batch file how it would run(security?). Also if a user was smart enough to read file they could get security information about the ftp server.

Could you please explain how i could do this using a batch file?
I am not familiar with signed applets and how they work, but i would be willing to do this if it worked as well.

thanx alot

Tom
> but i wasnt sure if when a computer downloaded a batch
> file how it would run(security?).

Same way an exe would run.
How did you intend for the exe to be run?

> Also if a user was smart enough to read file they could
> get security information about the ftp server.

Why would the batch need to contain security information about the ftp server?

> Could you please explain how i could do this using a batch file?

The batch would include the commands to execute to perform the upgrade.

> I am not familiar with signed applets and how they work

An applet is basically a Java application that is downloaded and runs inside the browser. Signing the applet is required to allow the user to grant it permission to access your hard disk. Signing involves attaching a digital certificate to the applet that confirms your identity.

An applet based solution would be nice in that the whole upgrade process could be controlled seamlessly from within the browser.
Is it feasible to have a generic exe, which you simply provide a configuration file to handle the upgrade?
ie. you would not need to generate the exe each time, just the config and a zip containing the files to install.
thanx for answer, i just need a little more clarification

>Same way an exe would run.
>How did you intend for the exe to be run?

First i tested using Winzip and when the self extracting exe file was downloaded it automatically unzipped and installed in specific directory, so it was just a matter of clicking a link on my page to zip file. Unfortunately, i found out our webserver is Solaris.  

>The batch would include the commands to execute to perform the upgrade.

So just to clarify,
My servlet or jsp could edit a batch file sitting on my server, then user could download this batch file that i generated.
Would this batch file be downloaded with the files in some kind of zip file?
If yes, would the user have to click on batch file to execute it?
What kind of commands would i use to put the files into a specific directory, just DOS commands?
Would there be and security restrictions on running this batch file?

>Why would the batch need to contain security information about the ftp server?

I thought the  batch file might contain ftp commands with the filenames to connect to remote ftp server and download that way?For this you would need username and password and ip of ftp server.

thanx again for all your help,

Tom
>Is it feasible to have a generic exe, which you simply provide a configuration file to handle the upgrade?
ie. you would not need to generate the exe each time, just the config and a zip containing the files to install.

that would be great if i could find the software that provides this function and is compatible with Solaris


Thanx
Tom
>Is it feasible to have a generic exe, which you simply provide a configuration file to handle the upgrade?
ie. you would not need to generate the exe each time, just the config and a zip containing the files to install.

that would be great if i could find the software that provides this function and is compatible with Solaris


Thanx
Tom
the self extract exe file consited with a extract header + the zip file itself.

the header part is always the same. you can easily use any programming language, including java, on any platform to construct a self extration .exe file from an .zip file.

let me know if you need further help.
ASKER CERTIFIED SOLUTION
Avatar of kennethxu
kennethxu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>Is it feasible to have a generic exe, which you simply provide a configuration file to handle the upgrade?
ie. you would not need to generate the exe each time, just the config and a zip containing the files to install.

that would be great if i could find the software that provides this function and is compatible with Solaris


Thanx
Tom
Regarding that link:

Could you please elaborate a little more on the creating a self-extracting exe with java.
It says change the last two bytes of the zip file to 58 00. Not sure what this means.

Also, does this mean i can use the same bin file for every self extracting exe?

Please let me know if you have anymore information on creating a self extracting exe in java that is for Windows2000.

thanx for your time

Tom
>> Could you please elaborate a little more on the creating a self-extracting exe with java. It says change the last two bytes of the zip file to 58 00. Not sure what this means.

you can use use java.io.FileInputStream read in head.bin, your zip file and tailer.txt, use java.io.RandaomFileAccess to write them to a xxx.exe file sequentially.
after you write the zip file, go back 2 bytes and write byte value 58 and 00 to the xxx.exe.

>> Also, does this mean i can use the same bin file for every self extracting exe?
yes!

let me know if you want me to write some example code for you.
That would be great if you could show me some sample code
because i understand that what to do now, but i am not totally sure how to do it.
How do i create the head.bin?
Is there a place where i can look at the format of a tailer.txt?
Can i just use a regular zip program to zip the files i need?
If i go back two bytes in my zip file, the value will be always 58 even if i create a new zip>?
Any idea what the purpose of changing this byte value is(just curious)?

thanx again for your time, this will clear up my question

Tom

>> How do i create the head.bin
just download if from the link I provided you, right click the head.bin and save as. if you have problem to download, I can send you a copy if you provide me your email address.

>> Can i just use a regular zip program to zip the files i need?
YES!

>> Is there a place where i can look at the format of a tailer.txt?
sorry, I don't have that detail information in a link, but if you have particular need, let me know and I'll try to dig it out for you. you can also download the tail.txt file from the link I provided (right click, save as), and you can change the path to C:\Cognos\Reports, that tail.txt configures the extract to be done silently in background and overwrite any existing files.

>> Any idea what the purpose of changing this byte value is(just curious)?
Not very sure, but it looks like a mark to tell extract code (in head.bin) that the tail.txt is appended.

>> That would be great if you could show me some sample code
here is the code, it worked for me, try it out.
I also found out that 58 00 should actually be the size of the tailer file, close to my previous guess. (the example tail.txt in the link is 88 (hex 58) bytes in size.)

import java.io.*;

public class SFXMaker {
    public static void main( String[] args )
        throws Exception
    {
          if( args.length != 2 ) {
               System.err.println( "Usage: java SFXMaker source.zip target.exe" );
               return;
          }
        OutputStream out = null;
        InputStream in = null;
          File zipfile = new File( args[0] );
          if( ! zipfile.exists() ) {
               System.err.println( args[0] + ": file doesn't exist" );
               return;
          }
        try {
               out = new BufferedOutputStream( new FileOutputStream( args[1] ) );
               in = new BufferedInputStream( new FileInputStream( "head.bin" ) );
               int c;
               while( ( c = in.read() ) != -1 ) out.write( c );
               in.close();

               in = new BufferedInputStream( new FileInputStream( zipfile ) );
               for( int ii = 0, length = (int)zipfile.length() - 2; ii < length; ii++ ) out.write( in.read() );
               in.close();
               
               File tailer = new File( "tail.txt" );
               long tailLength = tailer.length();
               out.write( (int) ( tailLength & 0xFF ) );
               out.write( (int) ( tailLength >> 8 ) );
               in = new BufferedInputStream( new FileInputStream( tailer ) );
               while( ( c = in.read() ) != -1 ) out.write( c );
               in.close();
          } finally {
               if( out != null ) try { out.close(); } catch( Exception e ) {}
               if( in != null ) try { in.close(); } catch( Exception e ) {}
          }
     }
}
               

awesome,
thanx alot for all your help

Tom
my pleasure and good luck!