Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6231877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:00:50+00:00 2026-05-24T10:00:50+00:00

When trying to run some code in online interpreters or with IRC bots, I

  • 0

When trying to run some code in online interpreters or with IRC bots, I always wonder which version of Scala they support.

Is there a way to retrieve the version of Scala from within the interpreter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:00:50+00:00Added an answer on May 24, 2026 at 10:00 am

    For Scala 2, use scala.util.Properties.versionNumberString (or versionString):

    scala> scala.util.Properties.versionString
    val res0: String = version 2.13.6
    
    scala> scala.util.Properties.versionNumberString
    val res1: String = 2.13.6
    

    For Scala 3, if you do the same thing, you may be surprised by the answer:

    % scala3 -version
    Scala code runner version 3.0.1 -- Copyright 2002-2021, LAMP/EPFL
    % scala3
    scala> scala.util.Properties.versionNumberString                                                                              
    val res0: String = 2.13.6
    

    That’s because Scala 3.0.x uses the Scala 2 standard library as-is, to aid migration, and makes only a small number of additions. (Eventually the standard libraries will no longer remain synchronized like this.)

    Here’s how to get the Scala 3 compiler version:

    scala> dotty.tools.dotc.config.Properties.simpleVersionString
    val res0: String = 3.0.1
    

    This only works if the scala3-compiler JAR is on your classpath. (In the standard Scala 3 REPL, it is; in some other environments, it might not be.)

    If the compiler isn’t on your classpath and you want the full Scala 3 version string, see Dmitrii’s answer.

    If the compiler isn’t on your classpath but you just want to find out at runtime whether you’re on Scala 2 or 3, well… perhaps there’s a cleaner/better way, you tell me, but one way that works is:

    util.Try(Class.forName("scala.CanEqual")).isSuccess
    

    Here, the choice of scala.CanEqual is arbitrary, it could be any of the small number of classes that are in scala3-library but not scala-library.

    But if you are tempted to go that route, you might instead consider including version-specific source in your project, or passing the Scala version via sbt-buildinfo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run some python code under Apache 2.2 / mod_python 3.2.8. Eventually
Where would set_include_path(../../); point to? I am trying to run some PHP code on
I am trying to run some code that will start a particular animation when
I have some code I am trying to run once my image has finished
I am trying to run some code from a book . There appears to
I am trying to run a buffer overflow example to run some code, but
I'm trying to run some queries to get rid of XSS in our database
I'm trying to run some commands in paralel, in background, using bash. Here's what
I am trying to run some unit tests in a C# Windows Forms application
I am trying to run PartCover to test the coverage of some tests with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.