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 4062434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:35:52+00:00 2026-05-20T15:35:52+00:00

One can write scripts in Scala. So you can put this into Hello.scala #!/bin/sh

  • 0

One can write scripts in Scala. So you can put this into Hello.scala

#!/bin/sh
exec scala $0 $@
!#

println("You supplied " + args.length + " arguments!")

and make it executable in Unix by

chmod u+x Hello.scala

Then you can run the script simply by

./Hello.scala

This compiles the script and runs it if there are no syntax errors. However, this does not account for situation when I only want to syntax check without executing the script. I do not want to modify the script (i.e. by removing the #! directive) and I do not want any *.class files to be generated.

How can I syntax check a Scala script?

  • 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-20T15:35:53+00:00Added an answer on May 20, 2026 at 3:35 pm

    I expect that you actually want a little more than just checking for correct syntax … presumably what you want to know is that your file would compile correctly if you did actually compile it. That involves type checking as well as syntax checking.

    For Scala source files (ie. not scripts) you can specify the -Ystop:refchecks command line argument to cause the compiler to stop before it starts code generation (if you really are only interested in syntactic correctness you could specify -Ystop:parser). If there are errors they will be shown on the console in exactly the same way as if you fully compiled the sources.

    For Scala scripts you can also specify the -Ystop:refchecks argument. If you do this, then you will either see compile errors reported on the console or, if there are no errors in the script, you will see the following,

    $ scala -Ystop:refchecks Hello.scala 
    java.lang.ClassNotFoundException: Main
    

    The ClassNotFoundException indicating that no classfiles have been generated and that your script has not been executed.

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

Sidebar

Related Questions

How can I write 'one bit' into a file stream or file structure each
How can I write a query similar to this one in LINQ to SQL
How would one write a sql server DDL script that can: For each table
In C++ one can write any of the following statements: 10; true; someConstant; //if
Asciidoc supports callouts . How can one write similar callouts using reStructuredText ?
I can write an assertion message one of two ways. Stating success: assertEquals( objects
Can we able to create two instance of log4j in class one to write
I ran Perl::Critic on one of my scripts, and got this message: Regular expression
It's possible to write shell scripts in Scala by starting a text file with:
I want to write two scripts. They can be VBS or Windows commands. The

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.