Create drag and drop feature to .desktop file in ubuntu
Posted By : Raman Joshi | 30-Sep-2015
In this blog we all see that how we can create .desktop file for ubuntu and enable it to listen drag and drop file absolute path. In my latest project we have the requirement to start transfering file on to the server via drag and drop to the icon of the project. So we have to create one launcher for that which listen file absolute path and transfer it to our java program which read that file path continues to file transfer process.
We have two process to start our application from .desktop file one is to write below script in .sh file and set the path of .sh file in Exec.
#!/bin/bash java -jar <path to jar>
And second is that we directly execute the jar from .desktop file in my case we have to set the direct path of jar as we need to start our application from drag and drop file into it.
So below is the exact code which we used to create .desktop file to start application and listen drop file.
[Desktop Entry] Comment=Caption Labs File Transfer Testing Name=CaptionLabsLocal #(Must same as .desktop file's name) Exec=java -jar <path to jar> %F Terminal=true Type=Application Icon=<path to jar> Categories=Development
As you can see that %F is use to listen the file path and it is use as the arguments in jar file. If you have any query regarding this you can mail me.