| Author |
"Executables" Win2000 - a solution
|
Peter Simard
Ranch Hand
Joined: Oct 31, 2001
Posts: 54
|
|
QUESTION Can you launch a Java application just by double-clicking a jar or class file? How do you set this up, without resorting to batch files? ANSWER Absolutely! You simply need to create the right file association and command-string for the target extension (in our case, �.jar� and �.class�). I tested this under Windows 2000, and found that it works� -------------------------------------------------------------------------------- HERE�S HOW To create a "double-clickable" jar file that automatically executes: (1) Get or change the file assocation via the "assoc" command. assoc .jar=jarfile (2) Create an open "command string" via the "ftype" command. ftype jarfile="C:\jdk1.3\bin\java.exe" -jar %1 You can do much the same with �.class� files. For more information on these commands, go to the command-line and type in: assoc /? ftype /? Or select F1 from the Windows desktop, and look them up. -------------------------------------------------------------------------------- WHAT TO EXPECT (1) You can double-click any jar file, and it will execute (provided it has a manifest.mf file with an entry point). (2) You can also execute a jar by typing its full name on the command-line, as in: C:\>fubar.jar See NOTE below for additional details... Either method causes Windows to execute the following command: C:\jdk1.3\bin\java.exe" -jar %1 where %1 is the name of the jar file you double-clicked. For example, given the file named "fubar.jar", the following command is issued: C:\jdk1.3\bin\java.exe" -jar fubar.jar -------------------------------------------------------------------------------- NOTE: you can obviate the need to type in the extension by modifying your PATHEXT environment variable. This environment variable stores the extensions of all files that can be executed, including EXE and BAT. You can add JAR to the lot by typing the following at the command-line: set PATHEXT=.jar;%PATHEXT% The same way you set the PATH environment variable, which stores the directories that should be searched for executables.
|
PAS<br />peter@panvox.net<br />2b || !2b
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
Thanks
|
"JavaRanch, where the deer and the Certified play" - David O'Meara
|
 |
 |
|
|
subject: "Executables" Win2000 - a solution
|
|
|