Error when adding Logback to classpath

依然范特西╮ 提交于 2019-12-25 04:24:53

问题


Whenever I try to run setClasspath.sh in logback-examples, I get an error. My logback setClasspath.sh file looks like this:

#!/bin/sh

##
# This script will add logback jars to your classpath.
##

LB_HOME=/home/darryl/logback

CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-classic-1.1.1.jar"
CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-core-1.1.1.jar"
CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/logback-examples-1.1.1.jar"
CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/lib/slf4j-api-1.7.6.jar"

export CLASSPATH

echo $CLASSPATH

However, when I run it, I get the following error:

: not foundath.sh: 2: ./setClasspath.sh: 
: not foundath.sh: 6: ./setClasspath.sh: 
: not foundath.sh: 8: ./setClasspath.sh: 
: not foundath.sh: 13: ./setClasspath.sh: 
: bad variable name14: export: CLASSPATH

Could someone tell me what's wrong?


回答1:


I downloaded and extracted latest logback version (logback-1.1.1.tar.bz2). This archive contains a logback-examples/setClasspath.sh script but this script is not executable by default. Actually, it's not stored with executable permissions in tar archive. I gave it executable permissions using:

chmod +x setClasspath.sh

I ran it and it complains about a carriage return at the end of line. (odd ^M character) Thus, this file uses wrong new line formats (windows format \r\n and not unix format: \n). You should just convert this file to unix format and try to run it again. Install dos2unix utility on your system. For your information, on debian or ubuntu, you can run this as root

apt-get install dos2unix

Then, as standard user, convert the file from dos format to unix/linux format:

dos2unix setClasspath.sh

You should probably notify logback guys about this small issue.



来源:https://stackoverflow.com/questions/22714163/error-when-adding-logback-to-classpath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!