|
1 |
| -# JavaCall |
| 1 | +# JavaCall.jl |
2 | 2 |
|
3 |
| -<!-- [](https://travis-ci.com/github/JuliaInterop/JavaCall.jl) --> |
4 |
| -<!-- [](https://travis-ci.com/github/JuliaInterop/JavaCall.jl) --> |
5 |
| -[](https://ci.appveyor.com/project/aviks/javacall-jl-6c24s) |
| 3 | + |
| 4 | + |
| 5 | +[](https://ci.appveyor.com/project/aviks/javacall-jl-6c24s) |
6 | 6 | [](https://gitter.im/JavaCall-jl/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
7 | 7 |
|
8 |
| - |
9 | 8 | Call Java programs from Julia.
|
10 | 9 |
|
11 | 10 | ## Documentation
|
12 | 11 |
|
13 | 12 | Documentation is available at http://juliainterop.github.io/JavaCall.jl
|
14 | 13 |
|
| 14 | +## Quick Start Example Usage |
| 15 | + |
| 16 | +```julia |
| 17 | +$ JULIA_COPY_STACKS=1 julia |
| 18 | + |
| 19 | +julia> using Pkg; Pkg.activate(; temp = true) |
| 20 | + Activating new project at `/tmp/jl_e6uPja` |
| 21 | + |
| 22 | +julia> using JavaCall |
| 23 | + │ Package JavaCall not found, but a package named JavaCall is available from a |
| 24 | + │ registry. |
| 25 | + │ Install package? |
| 26 | + │ (jl_e6uPja) pkg> add JavaCall |
| 27 | + └ (y/n) [y]: y |
| 28 | + |
| 29 | +... |
| 30 | + |
| 31 | +julia> JavaCall.addClassPath(pwd()) # Set appropriate classpath |
| 32 | + |
| 33 | +julia> JavaCall.addOpts("-Xmx1024M") # Use 1 GB of memory |
| 34 | +OrderedCollections.OrderedSet{String} with 1 element: |
| 35 | + "-Xmx1024M" |
| 36 | + |
| 37 | +julia> JavaCall.addOpts("-Xrs") # Disable signal handling in the JVM, reducing performance but enhancing compatability |
| 38 | +OrderedCollections.OrderedSet{String} with 2 elements: |
| 39 | + "-Xmx1024M" |
| 40 | + "-Xrs" |
| 41 | + |
| 42 | +julia> JavaCall.init() # Optionally, explicitly initialize the JVM. Do not use this in package `__init__()` to allow other packages to add class paths or options. |
| 43 | + |
| 44 | +julia> jls = @jimport java.lang.System |
| 45 | +JavaObject{Symbol("java.lang.System")} |
| 46 | + |
| 47 | +julia> out = jfield(jls, "out", @jimport java.io.PrintStream) |
| 48 | +JavaObject{Symbol("java.io.PrintStream")}(JavaCall.JavaLocalRef(Ptr{Nothing} @0x0000000003ecda38)) |
| 49 | + |
| 50 | +julia> jcall(out, "println", Nothing, (JString,), "Hello World") |
| 51 | +Hello World |
| 52 | +``` |
| 53 | + |
15 | 54 | ## Versions
|
16 | 55 |
|
17 | 56 | * 0.7 branch is currently being maintained for bug fixes only
|
18 | 57 | * master branch is currently proposed to be v0.8.0
|
19 | 58 |
|
20 |
| -## Non-Windows Operating Systems |
| 59 | +## Julia version compatability |
| 60 | + |
| 61 | +JavaCall should continue to work with Julia 1.0.x (formerly a long term support version of Julia). |
21 | 62 |
|
22 |
| -_JavaCall and its derivatives do not work correctly on Julia 1.1 and Julia 1.2. On Julia 1.3, please set the environment variable `JULIA_COPY_STACKS`. On 1.1 and 1.2, and on 1.3 without `JULIA_COPY_STACKS` set, you may see segfaults or incorrect results. This is typically due to stack corruption. The Julia long-term-support version of 1.0.x continues to work correctly as before._ |
| 63 | +JavaCall and its dependents do not work correctly on Julia 1.1 and Julia 1.2. On Julia 1.1 and 1.2, you may see segfaults or incorrect results. This is typically due to stack corruption. |
23 | 64 |
|
24 | 65 | For Julia pre-1.5, consider the [RootTaskRepl.jl](https://github.com/mkitti/RootTaskREPL.jl) package. With RootTaskREPL.jl, JavaCall is able to execute fine without the need of `JULIA_COPY_STACKS=1` with the exception of `@async` calls. Starting with the Julia 1.5, the REPL backend now runs on the root Task by default.
|
25 | 66 |
|
| 67 | +Julia 1.3.0 through Julia 1.6.2 are tested and guaranteed to work on Linux, macOS, and Windows via continuous integration. Julia 1.6.2 and newer should work on Linux and Windows. The `JULIA_COPY_STACKS` environment variable should be set to `1` on macOS and Linux, but not Windows. |
| 68 | + |
| 69 | +## Apple macOS |
| 70 | + |
| 71 | +JavaCall works on Julia 1.0 and Julia 1.3 to Julia 1.6.2. Please set the environment variable `JULIA_COPY_STACKS = 1`. |
| 72 | + |
| 73 | +As of Julia 1.6.3, JavaCall fails on macOS due to a fatal segmentation fault, signal (11). See [JavaCall#151](https://github.com/JuliaInterop/JavaCall.jl/issues/151) and [JuliaLang/julia#40056](https://github.com/JuliaLang/julia/pull/40056). |
| 74 | + |
| 75 | +The current developers of JavaCall do not posess current Apple hardware to debug this issue. [Help is needed.](https://github.com/JuliaInterop/JavaCall.jl/issues/151) |
| 76 | + |
| 77 | +Julia 1.0 and Julia 1.6.2 are tested via Github Actions continuous integration on macOS. |
| 78 | + |
26 | 79 | ## Windows Operating System
|
27 | 80 |
|
28 |
| -Do not set the environmental variable `JULIA_COPY_STACKS`. To use `jcall` with `@async` start Julia in the following way: |
| 81 | +Do not set the environmental variable `JULIA_COPY_STACKS` or set the variable to `0`. |
| 82 | + |
| 83 | +To use `jcall` with `@async`, start Julia in the following way: |
29 | 84 |
|
30 | 85 | ```
|
31 | 86 | $ julia -i -e "using JavaCall; JavaCall.init()"
|
32 | 87 | ```
|
| 88 | + |
| 89 | +Windows currently lacks support for multithreaded access to the JVM. |
| 90 | + |
| 91 | +Julia 1.0, 1.6, 1 (latest release), and nightly are tested on Windows via Github Actions continuous integration. |
| 92 | +x86 compatability is also tested on the latest Julia 1 release. |
| 93 | + |
| 94 | +## Linux |
| 95 | + |
| 96 | +On Julia 1.3 and newer, please set the environment variable `JULIA_COPY_STACKS = 1`. |
| 97 | + |
| 98 | +Multithreaded access to the JVM is supported as JavaCall version `0.8.0`. |
| 99 | + |
| 100 | +Julia 1.0, 1.6, 1 (latest release), and nightly are tested on Linux via Github Actions continuous integration. |
| 101 | + |
| 102 | +## Other Operating Systems |
| 103 | + |
| 104 | +JavaCall has not been tested on operating systems other than macOS, Windows, or Linux. |
| 105 | +You should probably set the environment variable `JULIA_COPY_STACKS = 1`. |
| 106 | +If you have success using JavaCall on another operating system than listed above, |
| 107 | +please create an issue or pull request to let us know about compatability. |
0 commit comments