theGreenCabbage
theGreenCabbage

Reputation: 4845

Creating an executable installer in Java

I am interested in making a one-click installer for my C# application.

I had the the framework of the application down. The logic of the application in the installer() method was:

public static void installer(){
        deleteLegacyFiles(); // deletes old files through a find method
        moveSQLite(); // moves the database file
        if(checkRevit2013()){ // checks whether Revit '13 is installed
            movePlugin2013(); // moves my plugin into the Addin folder or Revit
        }else if(checkRevit2014()){ // check whether Revit '14 is installed
            movePlugin2014(); // moves my plugin into the Addin folder or Revit
        }else{ 
            System.out.println("It does not look like you have either Revit 2013 or Revit 2014 installed.");
        }
    }

However, this Java script (not Javascript, but a Java script) really only took three folders from the /Desktop/ and copies them to their respective target folders. I am interested in a solution that turns all my three folders into one executable file (something like an .exe or .msi) and do the above actions.

Are there any solutions for this for Java? Something that packages multiple folders/files together and then allows for one-click solutions for installation? I'm not exactly how to phrase what I want, as this is my first software development project. Any suggestions are welcome.

Upvotes: 0

Views: 319

Answers (2)

Sunil Ramu
Sunil Ramu

Reputation: 58

Are you looking for making/building an executable jar file? If so you can use something like one-jar.

http://one-jar.sourceforge.net/index.php?page=introduction&file=intro

Here are the steps:

  1. Create an executable JAR file with your application's CLASS files in it. (Navigate to bin directory of workspace) Name this "main.jar" jar cfm main.jar manifest.txt *.class OR [jar cfm main.jar manifest.txt .]
  2. Create three directories: MAIN, LIB, and BOOT
  3. Place your "main.jar" file in the MAIN directory.
  4. Place the jar files that your main application depends on in the LIB directory.
  5. Naigate to Packaging- Create a new JAR file out of the MAIN and LIB directories. Name this one "MyUtil.jar". You do not need to add a manifest or do anything special to this file. It does not need to be executable. Just make it so that it contains the contents of the MAIN and LIB directories. jar cf MyUtil.jar main lib
  6. Extract the contents of the "one-jar-boot.jar" file into the BOOT directory.
  7. Navigate to the BOOT directory, and update the "MyUtil.jar" file with the following: jar -uvfm ../MyUtil.jar boot-manifest.mf .
  8. Your "MyUtil.jar" file should now be executable. Test it.

Upvotes: 0

henderso
henderso

Reputation: 1045

You can create a single executable jar file in java. This jar would have an application that does all the copying you've listed above. But instead of copying from the desktop, it would copy directories that are included in the executable jar. A jar is a zipped file type (in fact you can change the extension from jar to zip and examine the contents).

Your strategy will be to create a regular java application, package as an executable jar. Include the directories you want to install as resources in the jar. Check out the jar documentation for all java utility methods and classes to manipulate jars.

http://docs.oracle.com/javase/tutorial/deployment/jar/

Upvotes: 1

Related Questions