{"id":17111662,"url":"https://github.com/jbytecode/juliacaller","last_synced_at":"2025-07-31T14:35:19.947Z","repository":{"id":92231934,"uuid":"252665648","full_name":"jbytecode/juliacaller","owner":"jbytecode","description":"A library for calling Julia from Java","archived":false,"fork":false,"pushed_at":"2024-07-05T16:08:08.000Z","size":57,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T20:22:21.393Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbytecode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-03T07:47:38.000Z","updated_at":"2024-11-29T13:14:21.000Z","dependencies_parsed_at":"2024-11-07T18:04:26.746Z","dependency_job_id":"5f7413a4-abb7-483c-8917-0d1a51172901","html_url":"https://github.com/jbytecode/juliacaller","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbytecode%2Fjuliacaller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbytecode%2Fjuliacaller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbytecode%2Fjuliacaller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbytecode%2Fjuliacaller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbytecode","download_url":"https://codeload.github.com/jbytecode/juliacaller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657795,"owners_count":21140842,"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-10-14T16:56:44.955Z","updated_at":"2025-04-13T02:32:17.582Z","avatar_url":"https://github.com/jbytecode.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Build Status](https://travis-ci.org/jbytecode/juliacaller.svg?branch=master\u0026status=passed)](https://travis-ci.org/github/jbytecode/juliacaller)\n\n# JuliaCaller\n\nA library for calling Julia from Java.\n\n\n# Initials\nJuliaCaller creates a TCP server that listens on a special port in Julia side. This server executes \nJulia statements and expressions that sent from the Java side. The result is then handled in Java side as \nprimitives, JSONObjects and JSONArrays.\n\n## First things first!\nDon't forget to install the **JSON** package in your Julia environment before running JuliaCaller. JuliaCaller first tries to install the **JSON** package when its first use, however, this may take time and the maximum number of tries of connection may be exceed.\n\n```julia\n]add JSON\n```\n\nor \n\n```julia\njulia\u003e using Pkg\njulia\u003e Pkg.add(\"JSON\")\n```\n\n\n# javax.script interface\nJuliaCaller implements javax.script interface, that is, it can be used as a scripting engine in Java.\n\n# Examples\n\nHere is the section of examples. For now, we have only tests in the source code. Please have a look at the test folder.\n\n## Getting primitives\nThis example create a scripting environment for Julia. The statement 'a = 3' is sent to Julia and the result is handled from Java.\n```java\nConstants.setProperties(Constants.JULIA_PATH, \"/usr/local/bin/julia\");\nConstants.setProperties(Constants.JULIA_PORT, \"8001\");\n\n// Creating a scripting interface for Julia\nmanager = new ScriptEngineManager();\nengine = manager.getEngineByName(\"Julia\");\n\n// Sending command 'a = 3' to Julia from Java\nengine.eval(\"a = 3\");\n\n// Handling the result in Java\nObject a = engine.get(\"a\");\n```\n## Getting arrays\n```java\nConstants.setProperties(Constants.JULIA_PATH, \"/usr/local/bin/julia\");\nConstants.setProperties(Constants.JULIA_PORT, \"8001\");\n\n// Creating a scripting interface for Julia\nmanager = new ScriptEngineManager();\nengine = manager.getEngineByName(\"Julia\");\n\n// Creating array in Julia\nengine.eval(\"a = [1,2,3]\");\n\n// Handling result in Java\nObject result = engine.get(\"a\");\n\nassertTrue(result instanceof JSONArray);\n\nJSONArray arr = (JSONArray) result;\nassertEquals(1, arr.getInt(0));\nassertEquals(2, arr.getInt(1));\nassertEquals(3, arr.getInt(2));\n```\n\n## Function calls\n```java\nConstants.setProperties(Constants.JULIA_PATH, \"/usr/local/bin/julia\");\nConstants.setProperties(Constants.JULIA_PORT, \"8001\");\n\n// Creating a scripting interface for Julia\nmanager = new ScriptEngineManager();\nengine = manager.getEngineByName(\"Julia\");\n\n// Creating array in Julia\nengine.eval(\"a = [1,2,3]\");\nengine.eval(\"f(x) = sum(x) / length(x)\")\nengine.eval(\"b = f(a)\")\n\n// Handling result in Java\nObject result = engine.get(\"b\");\n```\n\n## Invocable interface\n```java\nConstants.setProperties(Constants.JULIA_PATH, \"/usr/local/bin/julia\");\nConstants.setProperties(Constants.JULIA_PORT, \"8001\");\n\n// Creating a scripting interface for Julia\nmanager = new ScriptEngineManager();\nengine = manager.getEngineByName(\"Julia\");\n\nInvocable invocable = (Invocable)engine;\nengine.eval(\"using Statistics\");\nengine.eval(\"a = [1.0, 2.0, 3.0]\");\n\n// The result is average of 1.0, 2.0, and 3.0\n// result = 2.0\nObject result = invocable.invokeFunction(\"mean\", \"a\");\n```\n\n# Using JuliaCaller without javax.script interface\n```java\ncaller = new JuliaCaller(\"/usr/local/bin/julia\", 8000);\ncaller.startServer();\ncaller.Connect();\n\ncaller.Execute(\"mypi = 3.14159265\");\nJSONObject obj = caller.GetAsJSONObject(\"mypi\");\n// Assertation is true\nassertEquals(obj.getDouble(\"mypi\"), 3.14159265);\n\n// Creating object 'myarray' in Julia\ncaller.Execute(\"myarray = [1,2,3,4,5]\");\n\n// Getting the array back in Java\nJSONArray obj = caller.GetAsJSONArray(\"myarray\");\n\n// Assertations are true\nassertEquals(obj.length(), 5);\nassertEquals(obj.getInt(0), 1);\nassertEquals(obj.getInt(1), 2);\nassertEquals(obj.getInt(2), 3);\nassertEquals(obj.getInt(3), 4);\nassertEquals(obj.getInt(4), 5);\n\ncaller.ShutdownServer();\n```\n\n# Easy passing of objects\n```java\nList\u003cDouble\u003e values = List.of(1.0, 2.0, 10.0, -4.0);\ncaller.addJuliaObject(JuliaObject.createArrayVariable(\"a\", values));\ncaller.Execute(\"using Statistics\");\ncaller.Execute(\"ave = mean(a)\");\ndouble result = caller.getDouble(\"ave\");\nassertEquals(2.25, result);\n```\n\nNote that the library is in its early development stage. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbytecode%2Fjuliacaller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbytecode%2Fjuliacaller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbytecode%2Fjuliacaller/lists"}