Remus32
Remus32

Reputation: 3

Scala Unable to access jarfile

I have the code:

val a = Seq("java","-jar \""+base.getCanonicalPath+"/sbt/sbt/bin/sbt-launch.jar\"")

val proc = Process(a)

proc.!<(
new ProcessLogger {override def buffer[T](f: => T): T = f

override def out(s: => String): Unit = println(s)

override def err(s: => String): Unit = println(s)
 })
}

But when i try to run it, it outputs:

Error: Unable to access jarfile "/home/remus32/.remus32/sbt/sbt/bin/sbt-launch.jar"

but the path is correct, when i try to run it in terminal it works, so where is the problem?

Upvotes: 0

Views: 1591

Answers (1)

childofsoong
childofsoong

Reputation: 1936

I find two problems with your code:

  1. Get rid of the quotes in the string (as a side note, if you were typing the quotes in terminal, many terminals use quotes as an alternative to having to escape special characters, so yours may have been doing that).
  2. Make the path to the jar a separate argument from the -jar one.

The following works for me (I did modify the path to be that of a sbt-launch jar from my own system, obviously):

val a = Seq("java","-jar", "/Users/soong/Library/Caches/IntelliJIdea13/sbt/sbt-launch.jar")
val proc = Process(a)
proc.!<(
    new ProcessLogger {override def buffer[T](f: => T): T = f

    override def out(s: => String): Unit = println(s)

    override def err(s: => String): Unit = println(s)
    })

Upvotes: 2

Related Questions