• Post Reply Bookmark Topic Watch Topic
  • New Topic

"Executables" Win2000 - a solution  RSS feed

Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

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�


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.


(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:


See NOTE below for additional details...

Either method causes Windows to execute the following

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:


The same way you set the PATH environment variable,
which stores the directories that should be
searched for executables.
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!