[英]Shell script to launch Java app won't execute
I am using debian and xterm. 我正在使用debian和xterm。
I have created a file 'run.sh' containing the following: 我创建了一个包含以下内容的文件“ run.sh”:
java -cp bin Main
read -n1 -r ip "Press any key to continue..." key
In Properties window I gave it permission to run as program. 在“属性”窗口中,我授予它作为程序运行的权限。
Double clicking the file does nothing. 双击文件不会执行任何操作。 Right click 'Execute' does nothing.
右键单击“执行”不执行任何操作。 Open-with UXTerm does nothing.
用UXTerm打开不执行任何操作。
If I open a terminal in the same directory and type 如果我在同一目录中打开终端并输入
java -cp bin Main
then it will run, but the shell script file never works. 然后它将运行,但是shell脚本文件永远无法运行。
What am I doing wrong here? 我在这里做错了什么?
You need to add a shebang line at the top of your file: #!/usr/bin/bash
. 您需要在文件顶部添加一个shebang行:
#!/usr/bin/bash
。 This tells the operating system that the file is in fact a bash executable rather than a normal file. 这告诉操作系统该文件实际上是bash可执行文件,而不是普通文件。 Alternatively, execute the script by entering
bash run.sh
from the command line. 或者,通过从命令行输入
bash run.sh
来执行脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.