Return to Snippet

Revision: 71099
at January 19, 2017 04:35 by laurenceosx


Updated Code
### Note: first line of .desktop file should start with [Desktop Entry] followed by key=value lines
### You can only have one Desktop Entry per .desktop file.
### Note option 2 allows you create a link and not have to copy the jar to the same dir as the link file.

### option 1

[Desktop Entry]
Type=Application
Name=vfs test.jar
Comment=### most import config item is JAR_NAME='name of your jar'
Exec=bash --rcfile "~/.bashrc" -ci "JAR_NAME='vfs test.jar' ; kdir=`dirname %k`; cd \\"$kdir\\"; java -jar \\"$JAR_NAME\\" %U"
Terminal=true

### option 2

[Desktop Entry]
Type=Application
Name=vfs test.jar
Comment=### most import config item is JAR_NAME='name of your jar'
Exec=bash --rcfile "~/.bashrc" -ci "JAR_NAME='vfs test.jar' ; kk=`readlink -f %k` ; kdir=`dirname \"$kk\"`; cd \\"$kdir\\"; java -jar \\"$JAR_NAME\\" %U"
Terminal=true

Revision: 71098
at January 19, 2017 04:28 by laurenceosx


Updated Code
### Note: first line of .desktop file should start with [Desktop Entry] followed by key=value lines
### You can only have one Desktop Entry per .desktop file.

### option 1

[Desktop Entry]
Type=Application
Name=vfs test.jar
Comment=### most import config item is JAR_NAME='name of your jar'
Exec=bash --rcfile "~/.bashrc" -ci "JAR_NAME='vfs test.jar' ; kdir=`dirname %k`; cd \\"$kdir\\"; java -jar \\"$JAR_NAME\\" %U"
Terminal=true

### option 2

[Desktop Entry]
Type=Application
Name=vfs test.jar
Comment=### most import config item is JAR_NAME='name of your jar'
Exec=bash --rcfile "~/.bashrc" -ci "JAR_NAME='vfs test.jar' ; kkk=`readlink -f %k` ; kdir=`dirname \"$kkk\"`; cd \\"$kdir\\"; java -jar \\"$JAR_NAME\\" %U"
Terminal=true

Revision: 71097
at January 19, 2017 02:33 by laurenceosx


Initial Code
[Desktop Entry]
Type=Application
Name=vfs test.jar
Comment=### most import config item is JAR_NAME='name of your jar'
Exec=bash --rcfile "~/.bashrc" -ci "JAR_NAME='vfs test.jar' ; kdir=`dirname %k`; cd \\"$kdir\\"; java -jar \\"$JAR_NAME\\" %U"
Terminal=true

Initial URL


Initial Description
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.

Initial Title
javaLauncher.desktop

Initial Tags


Initial Language
Bash