2

I'm trying to write a simple batch script to test my Scala program. The script should be something like this:

#!/bin/bash
scala ./build/classes/MyClass "../../res/some_file.txt"

This returns:

Exception in thread "main" java.lang.RuntimeException: Cannot figure out how to run target: ./build/classes/MyClass

If I'm in the classes directory running:

#!/bin/bash
scala MyClass "../../res/some_file.txt"

works as expected.

What am I doing wrong here?

-Lee

5
  • did you try replacing ./build with `pwd`/build? Commented Mar 1, 2012 at 19:58
  • Not sure I follow what you mean by pwd/build. Commented Mar 1, 2012 at 20:04
  • scala `pwd`/build/classes/MyClass "../../res/some_file.txt" Commented Mar 1, 2012 at 20:05
  • Yeah, I tried that.. no luck. Commented Mar 1, 2012 at 20:09
  • try: scala -classpath `pwd`/build/classes "../../res/some_file.txt" Commented Mar 1, 2012 at 20:39

1 Answer 1

7

You cannot pass the file name of a class -- you have to pass the class name, and it has to be in the classpath. So, instead, try this:

#!/bin/bash
scala -cp ./build/classes MyClass "../../res/some_file.txt"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.