开发者

How to auto-launch a jar file?

开发者 https://www.devze.com 2023-04-10 19:56 出处:网络
I have a game on a USB drive called MyGame.jar. It is an executable jar f开发者_JAVA技巧ile. I want to be able to put it on cd\'s and USB drives.

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

It is an executable jar f开发者_JAVA技巧ile. 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).


Creating an autorun.inf (Autorun.inf entries) will work quite nicely for a CD.

But for USB drives, as of Windows 7, it can't be done. Microsoft disabled this "feature" because of all the malware that auto-installed that way...

In your case, the contents of autorun.inf should be something like this:

[autorun]
shellexecute=MyGame.jar
icon=MyIcon.ico
label=MyGameName

shellexecute opens MyGame.jar automatically using the jre (if installed). The other lines are optional but good practice.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号