简体   繁体   English

我想制作在Ubuntu 12.04LTS中直接执行jar文件的sh文件

[英]I want to make sh file that execute jar file directly in Ubuntu 12.04LTS

In Ubuntu 12.04 (Not Working) 在Ubuntu 12.04中(不起作用)

I create a sh file and write the code. 我创建一个sh文件并编写代码。

  @echo off
  java -jar Program.jar

also allow the permission of execution. 也允许执行许可。 But no action performed. 但是没有执行任何动作。 While in windows it works fine. 在Windows中工作正常。

In Windows 7 (Working) 在Windows 7中(工作)

I create a batch file and write the code. 我创建一个批处理文件并编写代码。

@echo off
java -jar Program.jar

Please help what i am doing wrong. 请帮助我做错了。

Ubuntu shell scripts can't use @echo off that's for DOS command scripts. Ubuntu Shell脚本不能将@echo off用于DOS命令脚本。 You need something like, 您需要类似的东西,

#!/bin/sh
java -jar Program.jar

The first line is known as the Shebang (the #! is a kind of magic number ). 第一行称为Shebang#!是一种神奇的数字 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM