-
Notifications
You must be signed in to change notification settings - Fork 62
README
To run Erjang, you need to have Plain old Erlang, i.e. open source Erlang from Ericsson installed. This requirement will eventually go away. I test with version R16B02. Go to http://erlang.org/download.html, or google install erlang. If you don’t know how to install Erlang or already have it installed, then Erjang is probably not the thing for you yet.
Erjang uses primarily two things from The Erlang/OTP distribution:
- All the BEAM files (compiled
.erl
files) that make up the OTP library. - The
epmd
(erlang port-mapper daemon) which is a name server that runs on each machine so that Erlang VMs (called nodes) can find each other.
To build and Erjang, you also need Perl 5.10 or newer, and Java 7 or newer. If you’re on Linux, I recommend getting the Sun/Oracle JDK. IBM’s Java 6 for Linux works too, but for Erjang Sun’s JDK works better. You also need apache ant which is a Java build tool. If you’re on MacOS X you already have all these tools if you’re running a recently updated version.
You also need a copy of the Erjang source, either use git
to pull erjang from the repository here at github, or download a zip from here or a tarball from here
Now you should be able to simply cd into the source directory, and build erjang using ant. Simply run the command “ant”.
prompt$ cd erjang prompt$ ant
Now, set the environment variable ERL_ROOT
to the directory where you installed OTP. I use
prompt$ export ERL_ROOT=/Users/krab/Projects/erlang-R16B02
That’s it. Now you can start erjang with the jerl
command
prompt$ ./jerl Eshell V5.8 (abort with ^G) 1>
The first time you run Erjang it will launch … veerrryyy sloowwwly … because it is compiling a lot of .beam
files into java byte code. Subsequent launches will be significantly faster.
You can also start the Erjang GUI shell, using the ejc
script. That will bring up erjang in a separate window; and there you’ll have some better line editing and stuff. But the GUI code is somewhat buggy right now; I’m no Swing wizard.
Ant will some times pick up the wrong version of java (happened for me when I recently set up the CI server), i.e., you might for instance get the java that comes with GCC, and it will not work. Make sure that Java 6 is in your path; java -version
should print something like this.
krab@erjang01:~$ java -version java version "1.7.0_40" Java(TM) SE Runtime Environment (build 1.7.0_40-b43) Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
If you get this:
krab@erjang01:~$ java -version java version "1.5.0" gij (GNU libgcj) version 4.3.2 Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Then you’re in trouble. GIJ (GNU Interepreted Java) great for many things, but is only a Java 5; and also dog slow. [believe me, I wrote a fair part of it].
When running, it saves cached java bytecode into “~/.erjang/module-${CRC}.jar” (in the current directory). These files are written in response to erlang:load_module(Module,Binary).
These files also serve as a cache of files translated from beam → jar. If something goes astray, it may help to remove the .erj directory forcing Erjang to recompile next time it runs. At some point we’ll have to figure out a better way to cache these jar files [perhaps in ~/.erjang] because they end up being littered all over the place, taking up too much space.
To run e.g. the sample ring test, do
erjang$ ./jerl -pa src/main/erl -noshell -s ring main -s erlang halt
You can compare this to the output of running with plain old erlang
erjang$ erl -pa src/main/erl -noshell -s ring main -s erlang halt
Cheers!
Kresten Krab Thorup
krab at trifork dot com