2010-08-15 7 views
8

이 같은 자바에서 직접는 자바 애플 리케이션과 같은 스칼라 응용 프로그램을 실행 나는 다음과 로켓 발사 응용 프로그램을 실행하기 위해 노력하고있어

object HelloWorld { 
    def main(args: Array[String]) { 
     println("Hello World!") 
    } 
} 

을 :

java -cp scala-library.jar HelloWorld 

(분명히 스칼라와 compliling 후)

하지만 다음과 같은 오류 얻을 :

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld 
Caused by: java.lang.ClassNotFoundException: HelloWorld 
     at java.net.URLClassLoader$1.run(Unknown Source) 
(...) 
Could not find the main class: HelloWorld. Program will exit. 

나는 그것을 일하게하기 위해해야 ​​할 일이 사소한 일이라면 무엇을해야합니까? Java documentation에서

+0

봐 : http://en.wikipedia.org/wiki/Scala_%28programming_language%29, 나는 스칼라가 올바른 클래스 경로를 설정하는 기대, 즉 자바를 사용에서 누락되었습니다. –

답변

12

:

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.

작동해야 클래스 패스의 시작 부분에 .: (Windows에서 또는 .;)을 추가.

+0

감사합니다. 나는 그것이 사소한 것이 었습니다. :) –

0

시도하십시오 : 여기

java -cp %SCALA_HOME%\lib\scala-library.jar;. HelloWorld

+0

OP가 Windows를 사용하고 있습니까? –

관련 문제