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
5
  • 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
    – user271219
    Sep 30, 2014 at 3: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. Sep 30, 2014 at 4:05
  • Is there a way to add gnome-terminal before java to indicate where java should run?
    – user271219
    Sep 30, 2014 at 4:11
  • I don't know thats what I'm trying to find out xD Sep 30, 2014 at 4:17
  • I'll look into this for you tomorrow and I'll post back.
    – user271219
    Sep 30, 2014 at 4:43

1 Answer 1

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.

0

Not the answer you're looking for? Browse other questions tagged .