gpt4 book ai didi

scala - 将.jar添加到classpath(Scala)

转载 作者:行者123 更新时间:2023-12-03 12:09:02 24 4
gpt4 key购买 nike

因此,我一直在尝试使用signal-collect框架,并下载了.jar文件并将其提取到一个文件夹中。当前文件夹结构如下:

LICENSE.txt  
PageRank.scala
core-1.1.1-sources.jar
dependencies/
javaapi-1.1.1-sources.jar
NOTICE.txt
README.txt
core-1.1.1.jar
javaapi-1.1.1-javadoc.jar
javaapi-1.1.1.jar

其中 PageRank.scala是它们提供的Scala测试代码,它是:
import com.signalcollect._

object PageRank extends App {
val graph = GraphBuilder.build
graph.addVertex(new PageRankVertex(id=1))
graph.addVertex(new PageRankVertex(id=2))
graph.addEdge(new PageRankEdge(sourceId=1, targetId=2))
graph.addEdge(new PageRankEdge(sourceId=2, targetId=1))
graph.execute
graph.foreachVertex(println(_))
graph.shutdown
}

class PageRankVertex(id: Any, dampingFactor: Double=0.85)
extends DataGraphVertex(id=id, state=1-dampingFactor) {
type Signal = Double

def collect(oldState: Double, mostRecentSignals: Iterable[Double]): Double = {
1 - dampingFactor + dampingFactor * mostRecentSignals.sum
}

}

class PageRankEdge(sourceId: Any, targetId: Any)
extends DefaultEdge(sourceId, targetId) {
type SourceVertex = PageRankVertex

def signal(sourceVertex: PageRankVertex) = {
sourceVertex.state * weight / sourceVertex.sumOfOutWeights
}

}

关于JVM / Java / Scala,我是一个新手,这是我尝试将 .jar's添加到类路径中以编译 PageRank.scala:

$ scalac -classpath *.jar dependencies/*.jar PageRank.scala 
error: IO error while decoding core-1.1.1.jar with UTF-8
Please try specifying another one using the -encoding option
error: IO error while decoding javaapi-1.1.1-javadoc.jar with UTF-8
Please try specifying another one using the -encoding option
error: IO error while decoding javaapi-1.1.1-sources.jar with UTF-8
Please try specifying another one using the -encoding option
error: IO error while decoding javaapi-1.1.1.jar with UTF-8
Please try specifying another one using the -encoding option
error: IO error while decoding dependencies/je-3.2.76.jar with UTF-8
Please try specifying another one using the -encoding option
error: IO error while decoding dependencies/scala-library-2.9.1.jar with UTF-8
Please try specifying another one using the -encoding option
6 errors found

我无法弄清楚出了什么问题...发生了什么事?
谢谢!
问候,
-kstruct

最佳答案

您需要将两个类路径路径作为单个参数传递。

尝试这个:

$ scalac -classpath "*.jar:dependencies/*.jar" PageRank.scala
$ scala -classpath "*.jar:dependencies/*.jar" PageRank
PageRankVertex(id=2, state=0.9999999999999997)
PageRankVertex(id=1, state=0.9999999999999997)

它为我工作。

关于scala - 将.jar添加到classpath(Scala),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10077899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com