部署Scala 将Scala发布包解压即可,现解压到/opt/Scala下,目录结构为:
[godu@goduserver scala-2.9.1.final]\( pwd;ls /opt/Scala/scala-2.9.1.final bin doc lib meta misc src 编译和运行Scala程序 [godu@goduserver ScalaFiles]\) pwd /home/godu/ScalaFiles [godu@goduserver ScalaFiles]\( ls -l 总计 16 drwx------ 2 godu godu 4096 11-24 03:33 investments -rw------- 1 godu godu 205 11-24 03:33 UseInvestment.scala [godu@goduserver ScalaFiles]\) cat UseInvestment.scala import investments._ object UseInvestment { def main(args: Array[String]) { val investment = new Investment("XYZ Corporation", InvestmentType.STOCK) println(investment.getClass()) } } [godu@goduserver ScalaFiles]\( ls investments/ Investment.java InvestmentType.java [godu@goduserver ScalaFiles]\) cat investments/InvestmentType.java package investments; public enum InvestmentType { SHORT_TERM, BOND, STOCK, REAL_ESTATE, COMMODITIES, COLLECTIBLES, MUTUAL_FUNDS } [godu@goduserver ScalaFiles]\( cat investments/Investment.java package investments; public class Investment { private String investmentName; private InvestmentType investmentType; public Investment(String name, InvestmentType type) { investmentName = name; investmentType = type; } public int yield() { return 0; } } [godu@goduserver ScalaFiles]\) javac investments/InvestmentType.java [godu@goduserver ScalaFiles]\( javac investments/Investment.java [godu@goduserver ScalaFiles]\) /opt/Scala/scala-2.9.1.final/bin/scalac UseInvestment.scala [godu@goduserver ScalaFiles]$ java -cp /opt/Scala/scala-2.9.1.final/lib/scala-library.jar:. UseInvestment class investments.Investment