ubuntu - 在 Ubuntu 中执行脚本 .sh 后出现错误 "Unable to access jarfile"

标签 ubuntu path

执行 servidor.sh 时出现问题。它包含:

#!/bin/bash
echo "Running..."
java -jar $HOME/servidor.jar

我执行 servidor.sh 结果是:
alumno@uned:~$ sh servidor.sh
Running...
Error: Unable to access jarfile /home/alumno/servidor.jar

我在 VirtualBox 机器上的 Ubuntu 中。
servidor.jar 有权执行,我认为它位于正确的位置,因为我可以从 shell 使用 java -jar servidor.jar 启动它而不会出错:
alumno@uned:~$ java -jar servidor.jar
Inicializando servicios...
 >> ServicioAutenticacion
 >> ServicioDatos
 >> ServicioGestor

我已经尝试了其他帖子中的所有解决方案,但没有结果。
我疯了,因为我需要一个解决方案,但我不知道我还能做什么。

最佳答案

首先你需要检查 dos2unix 已安装在您的系统中,如果已安装,则运行以下命令 -

dos2unix myshellfile.sh

它有效..

如果您没有安装 dos2unix,请先安装它。

关于ubuntu - 在 Ubuntu 中执行脚本 .sh 后出现错误 "Unable to access jarfile",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21169724/

相关文章:

google-chrome - 从终端打开谷歌浏览器时出错

postgresql - 如何用 fig 恢复 postgres 数据库?

ubuntu - 无法从浏览器ERR_CONNECTION_TIMED_OUT访问Jenkins

c++11 - boost::filesystem::current_path() 返回空路径

path - 惯用地在 Rust Path 中展开波浪号

linux - 移动文件而不覆盖

java - UBUNTU 13.04 GNOME_DESKTOP_SESSION_ID

iphone - iOS - 沿曲线路径拖动对象

batch-file - 使用不属于当前目录的文件作为参数运行批处理时出错

node.js - 从 Node.js 中的另一个自定义模块访问自定义模块的正确路径表示法