Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jars via classpath #61

Closed
lawben opened this issue Feb 28, 2016 · 8 comments
Closed

Add jars via classpath #61

lawben opened this issue Feb 28, 2016 · 8 comments
Labels

Comments

@lawben
Copy link

lawben commented Feb 28, 2016

The new README does not state how to add local jars. In the current version load.jar() doesn't work anymore. Is it possible to load jars directly or do they need to be published to a local maven repo?

@alexarchambault
Copy link
Member

Yep, sorry, it should land here. That's like

classpath.addPath("/path/to/file.jar")

@Atry
Copy link

Atry commented Aug 9, 2017

It does not work now

cmd2.sc:1: not found: value classpath
val res2 = classpath.addPath("/path/to/file.jar")
           ^

@Atry
Copy link

Atry commented Aug 9, 2017

interp.load.cp is available. However it is not able to add a JAR from http URL.

@animeshsrivastava24
Copy link

animeshsrivastava24 commented Jul 10, 2018

If you want to add a local jar to Jupyter Scala , follow the instructions :

  1. Create a jar file for your project work
  2. Find the path to the jar
  3. Go to Jupyter Scala cell and type all the instructions in a single cell or split them in different cells as per your convenience

import ammonite., ammonite.ops.

val path = java.nio.file.FileSystems.getDefault().getPath("/home/animesh/Bureau/lastest_n2s3/out/artifacts/root_jar/root.jar") // here inside the " " add your path, I have added mine for example

val x = ammonite.ops.Path(path)

interp.load.cp(x)

It works for me, please check for yourself.

@Atry
Copy link

Atry commented Jul 11, 2018

I created an sbt plug-in for exporting classpath for Ammonite and Jupyter Scala

https://github.com/ThoughtWorksInc/sbt-ammonite-classpath/

@sunbuhui
Copy link

sunbuhui commented Oct 6, 2020

If someone used @animeshsrivastava24 code above and encountered compilation failed error below.
image
just comment frist line ‘import ammonite., ammonite.ops.’
image
Then it should work

@animeshsrivastava24
Copy link

@key2Love Can you explain how are you getting the value of x without importing the libraries?
Did you read your error code of twice import?

@sunbuhui
Copy link

sunbuhui commented Oct 7, 2020

@animeshsrivastava24 I didn't import the libraries before, it seems that almond imports these libraries automatically. I test this by restarting the kernel, the console still reported twice report error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants