When trying to run a .class file, Dolphin will ask me to choose an application to open/run it. However, using the java command doesn't remove the .class extension from the file, so it can't run. Is there any way to have the file extension removed so that the file will run correctly?

Edit: I've also tried commands like java ${1%.class} to no avail.

  • Do you have the command to run this .class in konsole? Usually you need to define a classpath either via the environment or with the -classpath switch. I think it might be easier working with a jar – Michael D. Jan 23 '17 at 20:25
  • Working with a jar file is a lot easier, actually. I've decided to take that route; for future reference though, is there any way to format the command given to Dolphin for applications? – diplomaticDeveloper Jan 23 '17 at 20:43

You can create a custom handler with a bash script:

create file /usr/local/bin/myhandler.sh

#!/usr/bin/env bash

echo $1

add executable flags sudo chmod +x /usr/local/bin/myhandler.sh

In dolphin > right click file > open with > (last entry not sure how it's called in english "own file, not in list") > insert /usr/local/bin/myhandler.sh enable all three checkboxes "execute in terminal", second "keep open after execution" and last one "default handler for all files"

Back to the myhandler.shscript:

$1 is the var keeping the full path to that file clicked in dolphin, you may want to adjust the bash script to something like

java -classpath /foo/bar $1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.