Version=1.0: Version of the desktop entry specification.
Type=Application: Indicates this is an application launcher.
Name=Java Archive Runner: The name that might appear in "Open With" dialogs (though NoDisplay=true often hides it from main menus).
Comment=Run executable Java Archive (.jar) files: A description.
Exec=java -jar %f:
java -jar: The command to execute Java archives.
%f: A placeholder that will be replaced by the full path to the single .jar file being opened. If you wanted to support opening multiple JARs at once (which doesn't make sense for java -jar), you'd use %F.
Icon=java: Tries to use an icon named "java". Most systems with Java installed will have a suitable icon (e.g., the Duke logo or a coffee cup). If not, a generic icon might be used. You could specify a full path to an icon file if you prefer.
Terminal=false: Set this to true if you want a terminal window to open when the JAR is launched. This is useful for console-based Java applications or for debugging, but usually false for GUI applications.
MimeType=application/java-archive;: This is crucial. It tells the system that this .desktop file knows how to handle files of the MIME type application/java-archive (which is the standard MIME type for .jar files).
Categories=Utility;Java;: Helps desktop environments categorize the application if it were to be shown in menus.
NoDisplay=true: This prevents the entry from showing up in your main application menu. It's intended purely as a file association target. If you wanted it in the menu, set this to false.
StartupNotify=true: Enables startup feedback (e.g., a spinning cursor) if the launched application supports it.
How to Use It:
Save the File:
Save the content above into a file named custom-java-launcher.desktop (or similar) in one of these locations:
Ensure java is in your PATH:
This launcher relies on the java command being available in your system's PATH environment variable. Test this by opening a terminal and typing java -version. If it works, you're good.
Update the Desktop Database:
After placing the file, you might need to update your system's desktop entry database. Open a terminal and run: