2

我有以下 Scala (2.10.1) 脚本:

#!/bin/bash

export CLASSPATH=${WORKSPACE}/build/classes/main:${WORKSPACE}/build/libs/setter-for-catan.jar

exec ${SCALA_HOME}/bin/scala "$0" "$@" 2>&1
!#

import sfc.board.SmallBoard

和:

$ cd ${WORKSPACE}
$ find build/classes/main -name 'SmallBoard*.class'
build/classes/main/sfc/board/SmallBoard$$anonfun$1.class
build/classes/main/sfc/board/SmallBoard$$anonfun$2.class
build/classes/main/sfc/board/SmallBoard$$anonfun$3.class
build/classes/main/sfc/board/SmallBoard$$anonfun$4.class
build/classes/main/sfc/board/SmallBoard$$anonfun$5.class
build/classes/main/sfc/board/SmallBoard$$anonfun$6.class
build/classes/main/sfc/board/SmallBoard$.class
build/classes/main/sfc/board/SmallBoard.class
$ jar tvf build/libs/setter-for-catan.jar | grep SmallBoard
  1272 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard$$anonfun$1.class
  1272 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard$$anonfun$2.class
  1276 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard$$anonfun$3.class
  1581 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard$$anonfun$4.class
  1103 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard$$anonfun$5.class
  1527 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard$$anonfun$6.class
  8097 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard$.class
  3722 Sun Jun 30 20:40:54 EDT 2013 sfc/board/SmallBoard.class

但是脚本没有找到 sfc 包,更不用说类了:

$ ./setter-for-catan.scala 
./setter-for-catan.scala:10: error: not found: object sfc
import sfc.board.SmallBoard
       ^
one error found

发生了什么事,需要做些什么来解决它?

4

1 回答 1

1

使用scala -cp ${CLASSPATH},不使用scala -classpath ${CLASSPATH}

于 2013-07-01T13:43:13.433 回答