posted 12 years ago
Well, the answer to your question is no, this isn't the only way to run it. There are two things you can do, assuming you are on Windows.
One is to associate the file type of ".jar" with a program; in this case, the Java SE binary. Look in Windows Explorer (NOT Internet Explorer) under "Tools / Options" and choose the "File Types" panel. Find or create the one for JAR files, and associate it with the Java SE Binary program.
However, that doesn't open a command line window to run the program; keep in mind that many Java programs are GUIs themselves, and don't need and wouldn't want a command line window open just to run them.
So the second thing you can do is create a batch file with the above command in it, then create a shortcut to that command file, and double-clicking that will run your java program. (the command window will then disappear, unless you have other commands in the batch file. Using "pause" is one way to keep it around until you click "Enter", in case there are messages to look at.) If your program is not a GUI, i.e., it outputs to a console and doesn't have SWT or Swing or something for display and control, this is about the only way to do it. You can double-click on it and have it run as above, but it won't show you anything at all -- no error messages, no output, zilch.
rc