?
Solved

JSP create self extracting exe to run on Windows but

Posted on 2003-03-08
18
Medium Priority
?
373 Views
Last Modified: 2010-04-01
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

0
Comment
Question by:tommyboy2214
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 4
18 Comments
 
LVL 92

Expert Comment

by:objects
ID: 8097001
Why does it need to be an exe, why not just use a batch file?
0
 
LVL 92

Expert Comment

by:objects
ID: 8097002
Or a signed Java applet.
0
 

Author Comment

by:tommyboy2214
ID: 8097068
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 92

Expert Comment

by:objects
ID: 8097124
> 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.
0
 
LVL 92

Expert Comment

by:objects
ID: 8097137
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.
0
 

Author Comment

by:tommyboy2214
ID: 8097174
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
0
 

Author Comment

by:tommyboy2214
ID: 8097176
>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
0
 

Author Comment

by:tommyboy2214
ID: 8097897
>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
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8099273
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.
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 2000 total points
ID: 8099467
Here you can find head.bin file and more info:
http://www.geocities.com/kennethxu/TechInfo/CreateZIPSFX/index.html
0
 

Author Comment

by:tommyboy2214
ID: 8099613
>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
0
 

Author Comment

by:tommyboy2214
ID: 8099663
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
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8100443
>> 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.
0
 

Author Comment

by:tommyboy2214
ID: 8101192
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

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8103658
>> 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.

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8103883
>> 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 ) {}
          }
     }
}
               

0
 

Author Comment

by:tommyboy2214
ID: 8104494
awesome,
thanx alot for all your help

Tom
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8105692
my pleasure and good luck!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question