Setting mapreduce.job.jar with a jar in path containing space

207 views Asked by At

I'm trying to write a mapreduce program and one of the step is set mapreduce.job.jar with a file. It the file is in a path that doesn't contain space, the program works fine. But the path contains space, the path is encoded, and I will get an no jar found error.

Say the job jar is under /home/myname/workspace/myMapReduce.jar When I set mapreduce.job.jar with this path, it's fine.

Configuration conf = job.getConfiguration();       
conf.set("mapreduce.job.jar", file.toURI().toURL().toString());

But if the path is /home/my name/workspace/myMapReduce.jar ( a space between 'my' and 'name'), the

file.toURI().toURL().toString()

encode the path into /home/my%20name/workspace/myMapReduce.jar, and this fails the mapreduce program because there is no such a jar under this directory.

So is there a way to set mapreduce jar in path containing space? Or else, how can I set mapreduce.job.jar other than using file.toURI().toURL().toString()?

1

There are 1 answers

7
Condla On

Did you try escaping the space character with '\'?

In your example: /home/my\ name/workspace/myMapReduce.jar