File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,28 @@ To connect a Scala REPL console to a process:
48
48
scalive <pid>
49
49
```
50
50
51
- ## How it works
51
+ ## How to add your own JARs
52
+
53
+ Scalive only automatically loads ` scala-library.jar ` , ` scala-compiler.jar ` , and
54
+ ` scala-reflect.jar ` . If you want to load additional classes in other JARs, first
55
+ add the JAR to the system class loader:
56
+
57
+ ```
58
+ val cl = ClassLoader.getSystemClassLoader.asInstanceOf[java.net.URLClassLoader]
59
+ val searchDirs = Array("/dir/containing/the/jar")
60
+ val jarbase = "mylib" // Will match "mylibxxx.jar", convenient when there's version number in the file name
61
+ scalive.Classpath.findAndAddJar(cl, searchDirs, jarbase)
62
+ ```
63
+
64
+ Now the trick is just quit the REPL console and open it again. You will be able
65
+ to use your classes in the JAR as normal:
66
+
67
+ ```
68
+ import mylib.foo.Bar
69
+ ...
70
+ ```
71
+
72
+ ## How Scalive works
52
73
53
74
Scalive uses the [ Attach API] ( https://blogs.oracle.com/CoreJavaTechTips/entry/the_attach_api )
54
75
to tell the target process to load an [ agent] ( http://javahowto.blogspot.jp/2006/07/javaagent-option.html ) .
You can’t perform that action at this time.
0 commit comments