Now herong.jar contains a small stand-alone application. But how to execute this JAR file?
That's easy. You can run a JAR file with the "java -jar" command like this:
C:\herong>java -jar herong.jar 60.0
Fahrenheit = 60.0
Celsius = 15.555555555555555
My TempraturConvertorBean - Version 1.00
Cool. Right? But you can make it even better. You can register JAR files to be automatically
opened by the "java -jar" command on Windows system to make JAR files "truly" executable.
Here is what I did to make this happen.
Warning: this following tutorial modifies Windows registry database. Please do not follow it
if you don't have enough knowledge about Windows system.
1. Go to Start > Run. And enter "regedit" followed by clicking OK. Registry Editor window shows up.
2. Go to [HKEY_CLASSES_ROOT\jarfile\shell\open\command]. You should see the current value like this:
("C:\Program Files\Java\j2re1.4.2\bin\javaw.exe" -jar "%1" %*). This was added when you install JDK
on your system.
3. Double click this value and change it to: ("C:\Program Files\Java\j2re1.4.2\bin\java.exe" -jar "%1" %*).
4. Open a command window and try this:
C:\herong>herong.jar 50
Fahrenheit = 50.0
Celsius = 10.0
My TempraturConvertorBean - Version 1.00
Better. Right? You can run any JAR files by just typing their file names now.
You can also double click any JAR files on Window Explorer now. Try it and see what happens.