English 中文(简体)
加入(Scala)
原标题:Adding .jar s to classpath (Scala)

因此,我一直试图与以下网站合作:-signal-collection。 框架和我下载了<代码>.jar<>/code>文档,将其提炼成倍数。 目前,组合结构类似:

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  

Where PageRank.scala is the Scala test code they provide, which is:

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
  }

}

I am a newbie when it comes to the JVM/Java/Scala, and this was my attempt at adding the .jar s to the classpath for compiling 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

I cannot figure out what is going wrong... what s happening? Thanks! Regards, -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)

它为我工作。

问题回答

看来,根据已安装的Java版本,列入多个JAR可能或不会奏效的班次中的野心。 我发现,,在StackOverflow的其他地方,见(指出,在你希望的回响之后,你可以有尽可能多的人,按空间分开):

scalac -classpath $(echo *.jar dependencies/*.jar | tr      : )  PageRank.scala
scala -classpath $(echo *.jar dependencies/*.jar | tr      : )  PageRank




相关问题
Refactor packages in a Jar

I have a requirement that i need to load two versions of a jar at once. To avoid class path collisions I d like to rename the packages of one of the jars. Then in source you could always easily ...

Directory list of JAR file within classpath

The typically method to reference a file contained with a JAR file is to use ClassLoader.getResource. Is there a way to get the contents of a directory within a JAR files (similar to java.io.File....

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Jar file resource not available?

My program has the following lines, works fine when run from Netbeans, JButton Button_1=new JButton(new ImageIcon(Phone_Dialer.class.getResource("Dir_Icons/"+"Key_1"+Botton_Color+".gif"))); But ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

loading from JAR files during deployment vs development

when i am loading some data into my java program, i usually use FileInputStream. however i deploy the program as a jar file and webstart, so i have to use getRessource() or getRessourceAsStream() to ...

热门标签