0

So, my goal is to have a .desktop analyze it and start the program, the part where I extract the information from the .desktop I have already done, the problem is to start the applications, if I do

Desktop.getDesktop (). Open (file);

obviously it opens it to me with the system launcher, which I don't want, I wanted to know if there are any libraries that recognize the file and try to run it with the correct software (Appimage, jar and others are a problem, if not I could just do sh "path")

asked May 26, 2022 at 6:30

1 Answer 1

1

The .desktop file should point to a shell script which calls java on the needed application, or run java directly on the needed application (I guess it's a jar file).

java -classpath <classpath> -jar <path_to_your_jar>
answered May 26, 2022 at 6:47
Sign up to request clarification or add additional context in comments.

3 Comments

I don't want to run my java program through a .desktop, I want to run the apps that are in the .desktop, the problem is that many use extensions like .AppImage example: [Desktop Entry] Name = Tiled GenericName = Map Editor Comment = Tile Map Editor TryExec = / home / gattolfo / Applications / Tiled-1.8.4-x86_64_45370181d608e5498c38076f1821f989.AppImage Exec = / home / gattolfo / Applications / Tiled-1.8.4-x86_64_45370181d608e5498c38076f1821f989.AppImage% F Terminal = false Type = Application
my bad, I didn't fully understand the question in the first place. you can use file -i <your_file> in order to check the mimetype for the given file, then take an appropriate action for every mimetype (maybe a case statement in the bash script which decides with which application the file should be openened)
Oh cool, this is a very good idea

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.