쉘 스크립트에서 Java 애플리케이션을 실행할 수 없습니다.

쉘 스크립트에서 Java 애플리케이션을 실행할 수 없습니다.

zip 패키지를 다운로드하고 압축을 푼 후 modelsphere.bat 파일을 modelsphere.sh에 복사하고 내용을 다음과 같이 변경합니다.

 java -ms64m -mx512m -ss16m -classpath "./modelsphere.jar:./resources.zip:./resources:./targets:./lib/jakarta-regexp-1.5/jakarta-regexp-1.5.jar:./lib/velocity-1.6.1/velocity-1.6.1.jar:./lib/jazzy-core/jazzy-core.jar:./lib/jython-2.2.1/jython.jar:./lib/velocity-1.6.1/lib/commons-collections-3.2.1.jar:./lib/velocity-1.6.1/lib/commons-lang-2.4.jar:./lib/lablib-checkboxtree-3.0.2.jar" org.modelsphere.sms.Application

그러나 "./modelsphere.sh" 명령을 사용하여 modelsphere.sh를 실행하면 다음 예외가 발생합니다.

 Exception in thread "main" java.lang.NoClassDefFoundError: org/modelsphere/sms/Application
Caused by: java.lang.ClassNotFoundException: org.modelsphere.sms.Application
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
.  Program will exit.in class: org.modelsphere.sms.Application

명령을 실행할 때,

java -ms64m -mx512m -ss16m -classpath "./modelsphere.jar:./resources.zip:./resources:./targets:./lib/jakarta-regexp-1.5/jakarta-regexp-1.5.jar:./lib/velocity-1.6.1/velocity-1.6.1.jar:./lib/jazzy-core/jazzy-core.jar:./lib/jython-2.2.1/jython.jar:./lib/velocity-1.6.1/lib/commons-collections-3.2.1.jar:./lib/velocity-1.6.1/lib/commons-lang-2.4.jar:./lib/lablib-checkboxtree-3.0.2.jar" org.modelsphere.sms.Application

"modelsphere.sh" 파일의 내용이므로 작동합니다.

왜? "modelsphere.sh" 쉘 파일로 Open ModelSphere를 어떻게 시작할 수 있나요?

누구든지 나에게 어떤 점을 줄 수 있습니까? 미리 감사드립니다.

답변1

아마도 DOS 줄 끝(\n 대신 \r\n)이 있을 것입니다. 보다http://mywiki.wooledge.org/BashFAQ/052

그리고 좋은 연습을 위해서는 파일의 첫 번째 줄에 다음과 같은 내용이 나와 있는지 확인해야 합니다.#!/bin/sh

관련 정보