如何从Scala本身获取Scala版本? [英] How do I get the Scala version from within Scala itself?

查看:347
本文介绍了如何从Scala本身获取Scala版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与命令行编译器选项无关.如何以编程方式在代码内部获取Scala版本?

This is not about command-line compiler options. How do I programmatically obtain the Scala version inside code?

或者,Eclipse Scala插件v2在哪里将scalac的路径存储在哪里?

Alternatively, where does the Eclipse Scala plugin v2 store the path to scalac?

推荐答案

这将在不访问scala-compiler.jar的情况下起作用:

This will work without access to scala-compiler.jar:

Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> util.Properties.versionString
res0: java.lang.String = version 2.9.1.final

这篇关于如何从Scala本身获取Scala版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆