Commit 0612a5d2 authored by Carlos Galindo's avatar Carlos Galindo
Browse files

Reorganize README, add troubleshooting steps and simple example.

parent 4efe56bb
Loading
Loading
Loading
Loading
+100 −28
Original line number Diff line number Diff line
@@ -10,36 +10,14 @@ This project consists of three modules:

## Build

Requirements: Java > 11, Erlang/OTP 24, Maven and Make.
Requirements: Java ≥ 11, Erlang/OTP 24, Maven and Make.

Just run `make release` to generate the zipped release `e-knife-VERSION.zip`.
You'll also find it unzipped in the `dist` folder, ready to be run.

### Build with another version of Erlang

Part of the process requires some communication with an Erlang process. To
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`.

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`.

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
```

## Run

Requirements: Java > 11 and Erlang/OTP 24
Requirements: Java ≥ 11 and Erlang/OTP 24

The release version contains a jar file and a folder (`ebin`) with additional resources.
It is important to keep them in the same directory.
@@ -48,7 +26,14 @@ You'll probably want to generate slices, so you should run e-Knife. Run it witho
to obtain a list and explanation of arguments.

```
java -jar path/to/eknife.jar [args]
java -jar path/to/eknife.jar
```

For example, to slice `test.erl` with the slicing criterion `5, Res` and save the slice
to `test-sliced.erl`, you can use the following command:

```
java -jar path/to/eknife.jar -i test.erl -l 5 -v Res -o test-sliced.erl
```

### View the sliced graph
@@ -68,9 +53,8 @@ use an interactive graphviz viewer, such as [XDot][xdot].

## Import into an IDE

Most IDEs will autodetect the structure from the Maven configuration files.

You'll need to run `make beams` to compile the necessary Erlang files before running the program.
In most Java IDEs you'll find an option to import an existing Maven project, and
thus load the project structure and settings from the `pom.xml` files.

Otherwise, you can treat each folder (EDG, e-Knife and Miscellanea) as a
separate module, with the following dependencies:
@@ -79,6 +63,8 @@ separate module, with the following dependencies:
* EDG requires Miscellanea.
* Miscellanea has no dependencies.

You'll need to run `make beams` to compile the necessary Erlang files before running the program.

## License

This project is licensed under GNU Affero Public License (Version 3.0), with the exception of the
@@ -87,3 +73,89 @@ and are licensed under the Apache License (Version 2.0).

You should have received a copy of the GNU Affero Public License along with this program.
If not, see https://www.gnu.org/licenses.

## Troubleshooting

### I can't use/install Erlang/OTP 24

Part of the process requires some communication with an Erlang process. To
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`.

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`.

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
```

Finally, [rebuild the project](#build).

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

e-Knife requires at least Java 11. Your version may be lower. You can check it
by running `java -version`. To install a more modern version, check the instructions
below, according to your operating system.

<details><summary>Linux</summary>

Search your package manager for a JDK (typically `openjdk`) with at least version 11.
If you don't know how to search or install packages, you can check [pkgs.org][pkgs-jdk].

</details>

<details><summary>macOS</summary>

Follow [this guide][java-install-macos].

</details>

<details><summary>Windows</summary>

Download and install the Microsoft build (.msi) from [their site][w10-java-download].

</details>

[pkgs-jdk]: https://pkgs.org/search/?q=jdk
[java-install-macos]: https://mkyong.com/java/how-to-install-java-on-mac-osx/
[w10-java-download]: https://docs.microsoft.com/en-us/java/openjdk/download

### Cannot run program "erl": error=2, No such file or directory

You haven't installed Erlang, or it is not correctly setup to be available
on your `PATH`. Please install Erlang/OTP 24. If you install a different version,
you may need to follow [the instructions above](#i-cant-useinstall-erlangotp-24).

<details><summary>Linux</summary>

Install the package `erlang` with the package manager included in your system.
If you don't know how to install packages, you can check [pkgs.org][pkgs-erlang].

</details>

<details><summary>macOS</summary>

Use your favourite package manager:

* Homebrew: `brew install erlang`
* MacPorts: `port install erlang`

</details>

<details><summary>Windows</summary>

You can download the Erlang/OTP installer from [Erlang Solutions][erlang-solutions].

</details>

[pkgs-jdk]: https://pkgs.org/search/?q=erlang
[erlang-solutions]: https://www.erlang-solutions.com/downloads
+3 −5
Original line number Diff line number Diff line
@@ -62,14 +62,12 @@ public class ErlConnection
		for (int id = 0; id < 10 && !connected; id++)
			try
			{
				final String localhostName = InetAddress.getLocalHost().getHostName();

				this.clientNodeName = this.defaultClientNodeName + id;
				this.serverNodeName = this.defaultServerNodeName + id;
				this.cookie = this.defaultCookie + id;
				this.openServer();
				this.clientNode = new OtpSelf(this.clientNodeName, this.cookie);
				this.serverNode = new OtpPeer(this.serverNodeName + "@" + this.clientNode.host());
				this.clientNode = new OtpSelf(this.clientNodeName + "@localhost", this.cookie);
				this.serverNode = new OtpPeer(this.serverNodeName + "@localhost");
				this.serverNode.setCookie(this.cookie);
				this.connection = this.clientNode.connect(this.serverNode);
				connected = true;
@@ -104,7 +102,7 @@ public class ErlConnection
		final File scriptsFile = this.config.getScriptsFile();
		this.serverProcess = runtime.exec(new String[] {"erl",
				"-pa", scriptsFile.getAbsolutePath(),
				"-sname", this.serverNodeName,
				"-name", this.serverNodeName + "@localhost",
				"-setcookie", this.cookie
		}, null);