Commit 7a18e18a authored by Carlos Galindo's avatar Carlos Galindo
Browse files

README: improve explanation of jinterface replacement

parent 9e6bf3cb
Loading
Loading
Loading
Loading
+41 −6
Original line number Diff line number Diff line
@@ -83,22 +83,57 @@ that end, the `jinterface` library must match the version of Erlang installed
in your machine. If your installation of Erlang is not OTP 24, you should replace
the bundled `jinterface` library with the one from your Erlang installation.

Before running `make`, replace the package `com.ericsson.otp.erlang` from
`e-Knife/src` with the one from your Erlang distribution,
at `lib/jinterface-VERSION/java_src`.
Before running `make`, you must replace the package `com.ericsson.otp.erlang`
from `e-Knife/src/main/java` with the one that corresponds to your Erlang version.
You can either copy the files from your local installation (if available) or
download it from the OTP repository. After that, [rebuild the project](#build).

#### Copy jinterface from existing installation

Your Erlang distribution will most likely be installed at `/usr/lib/erlang`,
`/usr/local/lib/erlang`, `~/.local/lib/erlang` or `/usr/local/Cellar/erlang/VERSION/lib/erlang`.
Then, the library is located in `lib/jinterface-VERSION/java_src`

In some distributions (such as Ubuntu), you may need to install the `erlang-jinterface`
package.

As an example:

```bash
pkg="com/ericsson/otp/erlang"
rm -rf e-Knife/src/$pkg
mv /usr/lib/erlang/lib/jinterface-1.12/java_src/$pkg e-Knife/src/$pkg
erlang="/usr/lib/erlang"
rm -rf e-Knife/src/main/java/$pkg
mv $erlang/lib/jinterface-1.12/java_src/$pkg e-Knife/src/main/java/$pkg
```

#### Download jinterface from the repository

Check the version of OTP that you have installed by running the following snippet ([credit][so1]):

```bash
erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell
```

Then, download the corresponding release:

```bash
VERSION=22.2.7
wget https://github.com/erlang/otp/archive/OTP-$VERSION.tar.gz
```

Finally, extract `lib/jinterface-$ver/java_src` to the corresponding location:
```bash
VERSION=22.2.7
pkg="com/ericsson/otp/erlang"
ji_path="lib/jinterface-1.10.1/java_src"
dest="e-Knife/src/main/java/$pkg"
rm -rf $dest
tar -xf OTP-$VERSION.tar.gz otp-OTP-$VERSION/$ji_path/$pkg
mv otp-OTP-$VERSION/$ji_path/$pkg $dest
rm -rf otp-OTP-$VERSION/
```

Finally, [rebuild the project](#build).
[credit]: https://stackoverflow.com/a/34326368

### UnsupportedClassVersionError: eknife/EKnife has been compiled by a more recent version of the Java Runtime