To make your program market ready, users should be able to start your program by double clicking a file. Support for this is not automatically provided for Java programs. Even double clicking an executable jar file will not start your program if the user’s computer isn’t set up correctly,

Why Not Just Use an Executable Jar File?

I first experienced the problem with double clicking executable jar files when I gave my daughter a copy of one of the first programs I was working on. I sent her the executable jar file and instructed her to double click the file to start my program. I had many Java tools installed on my computer.  When I installed those Java tools, file associations were set up so double clicking a .jar file would automatically call Java. However, my daughter had an unpack utility installed on her computer. The unpack utility was for unpacking any packed files, including jar files. So her computer had file associations set up so double clicking a .jar file would automatically unpack the jar file. Double clicking my program’s jar file on her computer unpacked it instead of calling Java.

Therefore, double clicking an executable jar file may have different behaviors on different computers. But as stated above, for your program to be market ready, users should be able to start your program by double clicking a file.

Could you Change the File Association?

You could code the installation of your program to automatically set a file association for .jar files to call Java. Then you would be assured that double clicking your executable jar file would start your program, at least until someone did something to change file associations on that computer again. However, I think changing such file associations for file types that may be used by many different programs takes too many liberties with another’s computer. Don’t you hate it when you install a program and it manipulates settings you didn’t want it to change?

Create an EXE Wrapper

Instead, I prefer to provide a separate file the user can double click to start the program. In other words, I create an .exe wrapper. An .exe wrapper is simply a small program file with an .exe extension that will call another type of program, in this case a Java program, with all the program’s required parameters. Double clicking that .exe file provides the exact response one has come to expect from .exe files. Plus, your program then has no dependencies on a file type association.

Doesn’t That Limit Your Program to Windows?

OK, so you’re thinking you went through all the trouble of writing a program in Java so it can run on any operating system, and now I am asking you to restrict it to Windows by starting it with an .exe wrapper.  Yes, it is true that the .exe wrapper I’m asking you to put around your program runs only in Windows. But take a look at other programs that are available for many different operating systems. Notice that they provide different installers for each operating system, even for those programs that were created using Java. Create the .exe wrapper only for the installer you create for the Windows operating system. You could provide other installers, and maybe other wrappers, for other operating systems.

jStart32

I looked at a few of the available free programs that I found that may be used to create an .exe wrapper for Java programs. Though it is an old program, and it has a quirk I need to work around, I found jStart32 to be by far the easiest to use. You can download jStart32 from http://sourceforge.net/projects/jstart32/.

What’s its quirk? It doesn’t recognize icon libraries. When you create the .exe wrapper, you may specify the .ico file for your program’s icon. jStart32 assigns the first icon in the icon library, which is typically very low resolution, as the program’s icon. See my blog article on Create Your Own Icons for an explanation of icon libraries and how to create your own. Fortunately, I can get around this quirk by assigning the full icon library to the .exe file as part of my program’s install wizard. This replaces the default, low resolution icon that was assigned by jStart32.

Conclusion

Make your program market ready by making it easy to use. Make it easy to use by allowing the user to start your program by double clicking a file. Therefore, one more step in deploying your Java programs should be to create an .exe wrapper for the Windows version of your program.

jStart32 makes it easy to create the .exe wrapper. However, if you use jStart32 to create the .exe wrapper, assign a full icon library to the .exe wrapper as part of the install process of your program.

 

Related posts:

  1. Create Your Own Icons
  2. What is Software Deployment?
  3. Integrated Help and a User’s Guide for Your Programs
  4. What’s The Easiest Way to Quickly Resize Photos?
  5. Windows 7 UAC: Permission Prompts and Access Errors

About the Author


2 Responses to Should You Create a Windows .EXE Wrapper for Java Programs?

  1. [...] a prior blog post, Should You Create an .EXE Wrapper for a Java Program, I discussed my favorite free tool for creating an .exe wrapper, jStart32. An .exe wrapper is [...]

  2. [...] Should You Create a Windows .EXE Wrapper for Java Programs … [...]

More Do-It-Yourself Java Games

More Do-It-Yourself Java Games: An Introduction to Java Graphics and Event-Driven Programming is the second book of the Do-It-Yourself Java Games series. You'll learn to create windows and dialogs, to add buttons and input fields, to use images and drawings, and to respond to keyboard input and mouse clicks and drags. You'll create 10 more games including several puzzles, a dice game, a word game, and a card game.

This book assumes you either have an understanding of basic Java programming or you have read the first book, Do-It-Yourself Java Games: An Introduction to Java Computer Programming. Read more.

Do-It-Yourself Java Games

Do-It-Yourself Java Games: An Introduction to Java Computer Programming uses a unique "discovery learning" approach to teach computer programming: learn Java programming techniques more by doing Java programming than by reading about them.

Through extensive use of fill-in blanks, with easy one-click access to answers, you will be guided to write complete programs yourself, starting with the first lesson. You'll create puzzle and game programs like Choose An Adventure, Secret Code, Hangman, Crazy Eights, and many more, and discover how, when, and why Java programs are written the way they are. Read more

Step-by-Step Tutorial

Many of the tips, techniques, and tools discussed in this blog are demonstrated in a detailed step-by-step tutorial in the book, This Little Program Went to Market, by Annette Godtland.

The book takes a computer program through the entire process of creating, deploying and distributing a program, then selling and marketing it (or any other product) on the Internet. Read more.