책을 사서 보고있는 초짜입니다. hello.scala질문이 있습니다. 여기에 올려도 되는건지요? ㅎ

264 views
Skip to first unread message

이즈재민

unread,
May 10, 2015, 6:49:33 PM5/10/15
to scala...@googlegroups.com
안녕하세요 닉 이즈재민입니다.
책을 사서 하고있는 초보이고요 항상 삽질이 많군요 ^^;

간단한 질문을 하고싶어서 왔습니다.

scala sdk를 설치하였습니다. 윈도우 환경이구요
해당 폴더에 cmd모드로 가서 "scala"를 입력하니 console로 빠지더라구요.

첵에서 74page 4단계: 스칼라 스크립트를 작성해보자 에서요.

hello.scala 파일을 만든후에 안에 내용은 
println("Hello, scala, world!")
라고 넣었습니다.

근데 이걸 실행하고 싶은데 아래와 같은 error가 항상 나오는데 google검색능력이 떨어지는지 안되는군요.? 도움을 받을수있을까요? 팁이라도 주면 검색해볼께요^^;

expected class or object definition
println("Hello, world, from a script!")
^

Message has been deleted

Jy Lee

unread,
May 10, 2015, 10:49:23 PM5/10/15
to scala...@googlegroups.com
일단 콘솔에서는
println("Hello, scala, world!")
를 그냥 실행하시면 원하는 결과를 얻으실 것 같아요!


2015년 5월 11일 월요일 오전 7시 49분 33초 UTC+9, 이즈재민 님의 말:

Jy Lee

unread,
May 10, 2015, 10:57:56 PM5/10/15
to scala...@googlegroups.com
그리고 책을보니 scala를 콘솔에 실행해서 scala 콘솔명령으로 실행하는게 아니고
일반 커맨드라인에서 실행하는 것으로 보입니다.
예를들면,
C:\> scala Hello.scala
Hello scala!
이런 식인것 같아요!

2015년 5월 11일 월요일 오전 11시 49분 23초 UTC+9, Jy Lee 님의 말:

이즈재민

unread,
May 10, 2015, 11:51:40 PM5/10/15
to scala...@googlegroups.com

답변감사합니다.
 
그냥 console에서println("~~")는 잘수행되었어요.
hello.scala 파일을 만들고 이 만든 파일을 출력하는게 안되서 질문올렸어요^^; 

Jy Lee

unread,
May 11, 2015, 3:42:28 AM5/11/15
to scala...@googlegroups.com
예를들면, Hello.scala 파일을 C:\에 만들었다면
C:\> scala Hello.scala (Enter) 를 하게 되면
Hello scala! (<-- 출력 결과)
이런 식인것 같아요!

2015년 5월 11일 월요일 오후 12시 51분 40초 UTC+9, 이즈재민 님의 말:

Hyunsok Oh

unread,
May 13, 2015, 9:04:34 PM5/13/15
to scala...@googlegroups.com
잘 됩니다. 안되신다니 이상하군요. 오류 내용을 긁어서 올리시면 도움이 될듯.
제가 해본 내용을 올립니다(windows 7에서 해서 copy con을 썼습니다.)

D:\x>copy con hello.scala
println("Hello, World!")
^Z
1 file(s) copied.

D:\x>scala hello.scala
Hello, World!

D:\x>scala
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_4
5).
Type in expressions to have them evaluated.
Type :help for more information.

단독으로 스칼라 파일을 실행하시려면 #! (해시-뱅)을 사용하고, 파일을 실행 가능 파일로 만들어야 합니다.

파일 내용이 대충 다음과 같이 바뀌죠.

$ cat hello2.scala
#!/usr/bin/env scala
println("Hello, World!")

$ chmod 755 hello2.scala
$ ./hello2.scala
Hello, World!

만약 윈도즈에서 해시뱅을 사용하려면

D:\x>type hello2.bat
::#!
@echo off
call scala %0 %*
goto :eof
::!#
println("Hello, World!")

D:\x>hello2.bat
Hello, World!

뭐 이런 식이 되죠.
> --
> 이 메일은 Google 그룹스 '라 스칼라 코딩단' 그룹에 가입한 분들에게 전송되는 메시지입니다.
> 이 그룹에서 탈퇴하고 더 이상 이메일을 받지 않으려면 scala-korea...@googlegroups.com에 이메일을
> 보내세요.
> 이 그룹에 게시하려면 scala...@googlegroups.com에 이메일을 보내세요.
> 웹에서 이 토론을 보려면
> https://groups.google.com/d/msgid/scala-korea/a16a82d4-cb16-4402-ac2c-dbd2a6c085f5%40googlegroups.com을(를)
> 방문하세요.
>
> 더 많은 옵션을 보려면 https://groups.google.com/d/optout을(를) 방문하세요.
Reply all
Reply to author
Forward
0 new messages