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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:25:56+00:00 2026-05-16T16:25:56+00:00

Under Windows, I can run a Scala script from a different directory using a

  • 0

Under Windows, I can run a Scala script from a different directory using a batch script like:

Hello.bat:

@scala "%~dp0Hello.scala" %*

(%~dp0 will be translated to the path where the batch file is)

So I can call it like this:

c:\somedir>path\to\scala\script\Hello
Hello World!
c:\somedir>path\to\scala\script\Hello Moon
Hello Moon!

Or, if the directory where the script is is already in the path, I could simply use:

c:\somedir>Hello
Hello World!
c:\somedir>Hello Moon
Hello Moon!

I can’t do the same thing for compiled classes:

@scala "%~dp0Hello.class" %*

won’t work, and

@scala -howtorun:object "%~dp0Hello.class" %*

wont’t work either, as well as

@scala -howtorun:object "%~dp0Hello" %*

This one:

@scala -howtorun:object "Hello" %*

only works if I am at the same directory, same as:

@scala Hello %*

And:

@cd %~dp0
@scala Hello %*

works, but it exits in the directory of the script, not where I was when I called it!

How can I tell scala where to find a class that I am trying to run?

  • 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-16T16:25:56+00:00Added an answer on May 16, 2026 at 4:25 pm

    (Let me know if I’ve misunderstood your question, as I suspect you know this already … )

    Classes to be executed must be on the classpath. Simply put you can either:

    set CLASSPATH=/path/to/where/your/base/package/is;%CLASSPATH%
    

    or you can put it explicitly in your scala invocation

    scala -classpath /path/to/where/your/base/package/is;%CLASSPATH%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I get a threads suspend count under Windows CE, using C or Visual
I am creating screenshots under Windows and using the LockBits function from GDI+ to
How can I run linux binary under windows? Is there some emulation jar or
i want to write a tcp server in c# under windows. can i run
Under Windows 7 I have a batch file for checking the status of some
Under windows, this F# code will extend a file from say 12 bytes out
When I run rake test under Windows, I see dots instead of test names.
I have installed android sdk under Windows 7. But when I run it, I
Currently I'm trying to run Eclipse Classic under Windows 7 x64, without success. First,
The following code will give a hard fail when run under Windows 7 32bit:

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.