Posted By

laurenceosx on 01/19/17


Versions (?)


 / Published in: Bash

For Ubuntu (might work on redhat too) create a nameOfYourJar.desktop file based on this snippet. You might have to also do command: chmod +x nameOfYourJar.desktop

You should also have your jar in the same directory as the desktop file.

This snippet also assumes java is in your current path (this is the reason for using the bash --rcfile -ci options).

This snippet so far seems space character friendly for jar names and paths with spaces and symbolic links with spaces in them (spaces commonly breaks lots of java start scripts).

I had to create this because my ubuntu installs don't always recognize jar files and don't always support the trick of creating a bash file with jar embedded inside it.

  1. ### Note: first line of .desktop file should start with [Desktop Entry] followed by key=value lines
  2. ### You can only have one Desktop Entry per .desktop file.
  3. ### Note option 2 allows you create a link and not have to copy the jar to the same dir as the link file.
  5. ### option 1
  7. [Desktop Entry]
  8. Type=Application
  9. Name=vfs test.jar
  10. Comment=### most import config item is JAR_NAME='name of your jar'
  11. Exec=bash --rcfile "~/.bashrc" -ci "JAR_NAME='vfs test.jar' ; kdir=`dirname %k`; cd \\"$kdir\\"; java -jar \\"$JAR_NAME\\" %U"
  12. Terminal=true
  14. ### option 2
  16. [Desktop Entry]
  17. Type=Application
  18. Name=vfs test.jar
  19. Comment=### most import config item is JAR_NAME='name of your jar'
  20. Exec=bash --rcfile "~/.bashrc" -ci "JAR_NAME='vfs test.jar' ; kk=`readlink -f %k` ; kdir=`dirname \"$kk\"`; cd \\"$kdir\\"; java -jar \\"$JAR_NAME\\" %U"
  21. Terminal=true

Report this snippet  


RSS Icon Subscribe to comments
Posted By: laurenceosx on January 19, 2017

I started using something like this to launch java apps on Ubuntu.

Posted By: Thanos on July 13, 2018

This is the use full update to all web users you have to need to online visit here for require to create the all history easily in to browser just getting the commend to helping you clear bing history and save to all setting for secure the browser forever thanks.

You need to login to post a comment.