Search code examples
javajarexecutable-jarexecute

How to auto-launch a jar file?


I have a game on a USB drive called MyGame.jar.

It is an executable jar file. I want to be able to put it on cd's and USB drives.

I want the game to start up automatically when the cd or USB is put into the computer, how can i do this?

The game will only be ran on Windows based computers(Windows Xp & Windows 7).


Solution

  • Here's how to automatically launch an application using autoplay:

    Make a text file and save it as autorun.inf. Save it in the base path of the CD.

    The contents of autorun.inf should look something like this:

    RUN=setup.exe
    Icon=icon.ico
    

    The icon field is optional.

    Note that this only works if the user has autoplay enabled. If the user disabled it, it won't work.