1+ # Scalive
2+
13This tool allows you to connect a Scala REPL console to running Oracle (Sun)
24JVM processes without any prior setup at the target process.
35
46[ ![ View demo video on YouTube] ( http://img.youtube.com/vi/h45QQ45D9P8/0.jpg )] ( http://www.youtube.com/watch?v=h45QQ45D9P8 )
57
68## Download
79
8- Download and extract
10+ For Scala 2.12, download
11+ [ scalive-1.7.0.zip] ( https://github.com/xitrum-framework/scalive/releases/download/1.7.0/scalive-1.7.0.zip ) .
12+
13+ For Scala 2.10 and 2.11, download
914[ scalive-1.6.zip] ( https://github.com/xitrum-framework/scalive/releases/download/1.6/scalive-1.6.zip ) ,
10- you will see:
1115
12- ```
13- scalive-1.6/
14- scalive
15- scalive.cmd
16- scalive-1.6.jar
17- jline-2.14.2.jar
16+ Extract the ZIP file, you will see:
1817
19- scala-library-2.10.6.jar
20- scala-compiler-2.10.6.jar
21- scala-reflect-2.10.6.jar
18+ ``` txt
19+ scalive-1.7.0/
20+ scalive
21+ scalive.bat
22+ scalive-1.7.0.jar
2223
23- scala-library-2.11 .8.jar
24- scala-compiler-2.11 .8.jar
25- scala-reflect-2.11 .8.jar
24+ scala-library-2.12 .8.jar
25+ scala-compiler-2.12 .8.jar
26+ scala-reflect-2.12 .8.jar
2627```
2728
2829scala-library, scala-compiler, and scala-reflect of the correct version
29- that your JVM process is using will be loaded, if they have not been loaded.
30+ that your JVM process is using will be loaded, if they have not been loaded yet .
3031The REPL console needs these libraries to work.
3132
32- For example, your process has already loaded scala-library 2.11 .8 by itself,
33+ For example, your process has already loaded scala-library 2.12 .8 by itself,
3334but scala-compiler and scala-reflect haven't been loaded, Scalive will
34- automatically load their version 2.11 .8.
35+ automatically load their version 2.12 .8.
3536
3637If none of them has been loaded, i.e. your process doesn't use Scala,
3738Scalive will load the lastest version in the directory.
3839
39- For your convenience, Scala 2.10.6 and 2.11.8 JARs are included above.
40+ For your convenience, Scala 2.12.8 JAR files have been included above.
4041
41- If your process is using a different Scala version, you need to manually
42+ If your process uses a different Scala version, you need to manually
4243download the corresponding JARs from the Internet and save them in the
4344same directory as above.
4445
4546## Usage
4647
47- Run the shell script ` scalive ` (* nix) or ` scalive.cmd ` (Windows).
48+ Run the shell script ` scalive ` (* nix) or ` scalive.bat ` (Windows).
4849
4950Run without argument to see the list of running JVM process IDs on your local machine:
5051
51- ```
52+ ``` sh
5253scalive
5354```
5455
5556Example output:
5657
57- ```
58+ ``` txt
5859JVM processes:
5960#pid Display name
606113821 demos.Boot
@@ -63,7 +64,7 @@ JVM processes:
6364
6465To connect a Scala REPL console to a process:
6566
66- ```
67+ ``` sh
6768scalive < process id listed above>
6869```
6970
@@ -80,7 +81,7 @@ Scalive only automatically loads `scala-library.jar`, `scala-compiler.jar`,
8081If you want to load additional classes in other JARs, first run these in the
8182REPL console to load the JAR to the system class loader:
8283
83- ```
84+ ``` scala
8485val cl = ClassLoader .getSystemClassLoader.asInstanceOf [java.net.URLClassLoader ]
8586val jarSearchDirs = Array (" /dir/containing/the/jar" )
8687val jarPrefix = " mylib" // Will match "mylib-xxx.jar", convenient when there's version number in the file name
@@ -90,7 +91,7 @@ scalive.Classpath.findAndAddJar(cl, jarSearchDirs, jarPrefix)
9091Now the trick is just quit the REPL console and connect it to the target process
9192again. You will be able to use your classes in the JAR normally:
9293
93- ```
94+ ``` scala
9495import mylib .foo .Bar
9596...
9697```
@@ -99,13 +100,13 @@ import mylib.foo.Bar
99100
100101## How Scalive works
101102
102- Scalive uses the [ Attach API] ( https://blogs.oracle.com/CoreJavaTechTips/entry/the_attach_api ) in Java 6
103+ Scalive uses the [ Attach API] ( https://blogs.oracle.com/CoreJavaTechTips/entry/the_attach_api )
103104to tell the target process to load an [ agent] ( http://javahowto.blogspot.jp/2006/07/javaagent-option.html ) .
104105
105106Inside the target progress, the agent creates a REPL interpreter and a
106107TCP server to let the Scalive process connect and interact with the
107108interpreter. The Scalive process acts as a TCP client. There are 2 TCP
108- connections, one for REPL data and one for completion data.
109+ connections, one for REPL data and one for tab key completion data.
109110
110111Similar projects:
111112
@@ -118,7 +119,7 @@ For simplicity and to avoid memory leak when you attach/detach many times,
118119Scalive only supports processes with only the default system class loader,
119120without additional class loaders. Usually they are standalone JVM processes,
120121like
121- [ Play] ( http://www.playframework.com/ ) or
122- [ Xitrum] ( http://xitrum-framework.github.io/ ) in production mode.
122+ [ Play] ( http://www.playframework.com ) or
123+ [ Xitrum] ( http://xitrum-framework.github.io ) in production mode.
123124
124125Processes with multiple class loaders like Tomcat are currently not supported.
0 commit comments