0

I have a runnable .jar file, which i can run from my linux terminal but I need to run that .jar file using a .sh file.

#!/bin/bash
java -jar executer.jar

If i double click the .sh file, terminal opens up but my code doesn't get executed. Kindly let me know, whats wrong.

lokesh
  • 39
  • 9
  • If you run this script from terminal everything works? – talex Nov 09 '18 at 07:18
  • may be try this https://askubuntu.com/questions/138908/how-to-execute-a-script-just-by-double-clicking-like-exe-files-in-windows – Deadpool Nov 09 '18 at 07:18
  • More specifically, can you run the java line in a bash terminal? – Roy Shahaf Nov 09 '18 at 07:19
  • If i try to run the .sh file from terminal am getting the following error "Unable to access jarfile/executer.jar" – lokesh Nov 09 '18 at 07:21
  • @RoyShahaf Yes, using terminal i can run the java line alone. it's working fine. But if i try to run the script, above error is displayed. – lokesh Nov 09 '18 at 07:24
  • Is the script in the same folder as the jar? – Roy Shahaf Nov 09 '18 at 07:27
  • At any rate this looks similar to https://stackoverflow.com/questions/11943948/what-causes-unable-to-access-jar-file-error . Try moving both script and the jar into a different folder (or using chmod to alter the permissions) – Roy Shahaf Nov 09 '18 at 07:29

2 Answers2

1

Try moving into sh file location using terminal and try to execute it using following command.

 ./startup.sh 

If your file name is 'startup'

Sandunka Mihiran
  • 486
  • 4
  • 19
0

Try to execute a command to output a log file.

Then check the log info.

java -jar executer.jar >err.log 2>1

BSMP
  • 4,242
  • 8
  • 33
  • 43