{"id":13801473,"url":"https://github.com/xitrum-framework/scalive","last_synced_at":"2025-05-13T11:31:14.111Z","repository":{"id":13612687,"uuid":"16305822","full_name":"xitrum-framework/scalive","owner":"xitrum-framework","description":"Connect a Scala REPL to running JVM processes without any prior setup","archived":false,"fork":false,"pushed_at":"2019-01-30T13:34:32.000Z","size":155,"stargazers_count":196,"open_issues_count":7,"forks_count":12,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-11-18T16:57:32.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://youtu.be/h45QQ45D9P8","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xitrum-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-28T08:11:24.000Z","updated_at":"2024-07-19T02:57:48.000Z","dependencies_parsed_at":"2022-08-28T07:52:21.981Z","dependency_job_id":null,"html_url":"https://github.com/xitrum-framework/scalive","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xitrum-framework%2Fscalive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xitrum-framework%2Fscalive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xitrum-framework%2Fscalive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xitrum-framework%2Fscalive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xitrum-framework","download_url":"https://codeload.github.com/xitrum-framework/scalive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932831,"owners_count":21986458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:23.194Z","updated_at":"2025-05-13T11:31:10.884Z","avatar_url":"https://github.com/xitrum-framework.png","language":"Java","readme":"# Scalive\n\nThis tool allows you to connect a Scala REPL console to running Oracle (Sun)\nJVM processes without any prior setup at the target process.\n\n[![View demo video on YouTube](http://img.youtube.com/vi/h45QQ45D9P8/0.jpg)](http://www.youtube.com/watch?v=h45QQ45D9P8)\n\n## Download\n\nFor Scala 2.12, download\n[scalive-1.7.0.zip](https://github.com/xitrum-framework/scalive/releases/download/1.7.0/scalive-1.7.0.zip).\n\nFor Scala 2.10 and 2.11, download\n[scalive-1.6.zip](https://github.com/xitrum-framework/scalive/releases/download/1.6/scalive-1.6.zip).\n\nExtract the ZIP file, you will see:\n\n```txt\nscalive-1.7.0/\n  scalive\n  scalive.bat\n  scalive-1.7.0.jar\n\n  scala-library-2.12.8.jar\n  scala-compiler-2.12.8.jar\n  scala-reflect-2.12.8.jar\n```\n\nscala-library, scala-compiler, and scala-reflect of the correct version\nthat your JVM process is using will be loaded, if they have not been loaded yet.\nThe REPL console needs these libraries to work.\n\nFor example, your process has already loaded scala-library 2.12.8 by itself,\nbut scala-compiler and scala-reflect haven't been loaded, Scalive will\nautomatically load their version 2.12.8.\n\nIf none of them has been loaded, i.e. your process doesn't use Scala,\nScalive will load the lastest version in the directory.\n\nFor your convenience, Scala 2.12.8 JAR files have been included above.\n\nIf your process uses a different Scala version, you need to manually\ndownload the corresponding JARs from the Internet and save them in the\nsame directory as above.\n\n## Usage\n\nRun the shell script `scalive` (*nix) or `scalive.bat` (Windows).\n\nRun without argument to see the list of running JVM process IDs on your local machine:\n\n```sh\nscalive\n```\n\nExample output:\n\n```txt\nJVM processes:\n#pid\tDisplay name\n13821\tdemos.Boot\n17978\tquickstart.Boot\n```\n\nTo connect a Scala REPL console to a process:\n\n```sh\nscalive \u003cprocess id listed above\u003e\n```\n\nJust like in normal Scala REPL console, you can:\n\n* Use up/down arrows keys to navigate the console history\n* Use tab key for completion\n\n## How to load your own JARs to the process\n\nScalive only automatically loads `scala-library.jar`, `scala-compiler.jar`,\n`scala-reflect.jar`, and `scalive.jar` to the system classpath.\n\nIf you want to load additional classes in other JARs, first run these in the\nREPL console to load the JAR to the system class loader:\n\n```scala\nval cl            = ClassLoader.getSystemClassLoader.asInstanceOf[java.net.URLClassLoader]\nval jarSearchDirs = Array(\"/dir/containing/the/jar\")\nval jarPrefix     = \"mylib\"  // Will match \"mylib-xxx.jar\", convenient when there's version number in the file name\nscalive.Classpath.findAndAddJar(cl, jarSearchDirs, jarPrefix)\n```\n\nNow the trick is just quit the REPL console and connect it to the target process\nagain. You will be able to use your classes in the JAR normally:\n\n```scala\nimport mylib.foo.Bar\n...\n```\n\n[Note that `:cp` doesn't work](http://stackoverflow.com/questions/18033752/cannot-add-a-jar-to-scala-repl-with-the-cp-command).\n\n## How Scalive works\n\nScalive uses the [Attach API](https://blogs.oracle.com/CoreJavaTechTips/entry/the_attach_api)\nto tell the target process to load an [agent](http://javahowto.blogspot.jp/2006/07/javaagent-option.html).\n\nInside the target progress, the agent creates a REPL interpreter and a\nTCP server to let the Scalive process connect and interact with the\ninterpreter. The Scalive process acts as a TCP client. There are 2 TCP\nconnections, one for REPL data and one for tab key completion data.\n\nSimilar projects:\n\n* [liverepl](https://github.com/djpowell/liverepl)\n* [scala-web-repl](https://github.com/woshilaiceshide/scala-web-repl)\n\n## Known issues\n\nFor simplicity and to avoid memory leak when you attach/detach many times,\nScalive only supports processes with only the default system class loader,\nwithout additional class loaders. Usually they are standalone JVM processes,\nlike\n[Play](http://www.playframework.com) or\n[Xitrum](http://xitrum-framework.github.io) in production mode.\n\nProcesses with multiple class loaders like Tomcat are currently not supported.\n","funding_links":[],"categories":["Testing","Table of Contents"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxitrum-framework%2Fscalive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxitrum-framework%2Fscalive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxitrum-framework%2Fscalive/lists"}