0

I have library jar file in IBM COS which I want to add to a scala notebook in watson stdio. I want to use %addJar but not sure what should be the URL to access the object. When I right click the object I get URL "cos://" which addJars does not recognize. Thanks

miri
  • 1
  • 1

1 Answers1

0

I’m assuming you are using a python notebook using the Apache Spark service and the jar file is in your project’s cos bucket (please update your question if these assumptions are incorrect).

One option is to use project-lib to download the jar and write it to the libs folder on the spark service:

from project_lib import Project
project = Project(sc,"<ProjectId>", "<ProjectToken>")

# Get the file
mem_jar_file = project.get_file("your.jar")
mem_jar_file.seek(0)

with open('~/data/libs/your.jar', 'wb') as f:
    f.write(mem_jar_file.read())

Update

If you are using Scala, one option is to:

  1. Use the IBM Cloud Object Storage java library to retrieve the file
  2. Write the jar file to appropriate folder
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
  • Thanks, I'm actually using scala notebook. How can I do this in scala? Thanks – miri Jun 04 '18 at 12:04
  • I've updated the answer. Unfortunately, I think Scala will be a lot more work. – Chris Snow Jun 04 '18 at 12:20
  • Thanks unfortunately for the two solutions I am getting back to my original problem: I have a library in jar file I want to access from the notebook so writing another java library will not help me -- I will need to access that library again. – miri Jun 05 '18 at 05:29