1

I'm having a problem executing a shell script in ubuntu, the script is set as executable and I enabled the execute instead of view option in Nautilus and the script does what it's meant to do which is launch a java jar, but it doesn't open the terminal and the app requires interaction from the terminal to function. How do I make it so that it runs the script from within terminal?

Also, I'm using Ubuntu 14.04 LTS and here is the script:

#!/bin/bash
java -jar example.jar
  • Instead of using the script, try running directly from a terminal java -jar example.jar and see what happens. If the same output is received, this might mean that's just the way the app run. Also consider checking this answer How do I run a .JAR file via the terminal –  Sep 30 '14 at 03:58
  • No it works, doing ./run.sh (and java -jar example.jar) makes everything run as expected, its just that double clicking the script starts the process but not in terminal, I know this because I have to kill the process in task manager to run more than one instance of the process. – juanjalvarez Sep 30 '14 at 04:05
  • Is there a way to add gnome-terminal before java to indicate where java should run? –  Sep 30 '14 at 04:11
  • I don't know thats what I'm trying to find out xD – juanjalvarez Sep 30 '14 at 04:17
  • I'll look into this for you tomorrow and I'll post back. –  Sep 30 '14 at 04:43

1 Answers1

2

You can run your java command in a gnome-terminal this way:

gnome-terminal -x bash -c "java -version; bash"

Or to take your example:

gnome-terminal -x bash -c "java -jar example.jar; bash"

You could even specify where to run your command:

gnome-terminal --working-directory=WORKING_DIR -x bash -c "java -jar example.jar; bash"

Running a bash command after the java one allow gnome-terminal to stay open even after the command is completed.