forked from erlang/erlide_eclipse
-
Notifications
You must be signed in to change notification settings - Fork 3
Tutorial Hello World
Vlad Dumitrescu edited this page Oct 27, 2010
·
1 revision
Thanks to Alain O'Dea for writing this guide.
- Ubuntu Linux: run the following in Terminal: sudo apt-get update sudo apt-get install erlang
- Windows: run the Windows Installer for Erlang
- Mac OS X: install MacPorts and then run the following in Terminal: sudo port selfupdate sudo port install erlang
- Download Eclipse IDE for Java Developers
- Extract it where you want to run it from (there is no installer, just an archive)
- Launch Eclipse by double-clicking eclipse (Linux), eclipse.exe (Windows), or Eclipse (Mac) in the eclipse folder
- Select Help (menu) -> Software Updates... (a dialog will appear)
- Click Add Site...(another dialog will appear)
- Enter http://erlide.erlide.org/update into the Location field, then click OK (dialog will close)
- Select the checkbox by
http://erlide.org/updateand click Install... (another dialog will appear) - Select Next
- Select I accept ... radio button and click Finish (a progress dialog will appear)
- (wait for confirmation dialog) Select Yes (Eclipse will restart)
Without these steps things like syntax highlighting, code completion and other significant aspects of the ErlIDE UI will not work properly. The IDE will function basically, but it will not work as intended.
- Select Window (menu) -> Preferences... (Windows/Linux) or Eclipse (menu) -> Preferences... (Mac) (a dialog will appear)
- Expand Erlang and select Installed runtimes
- Click Add... (a dialog will appear) and Enter Erlang in the Runtime name field
- Click Browse... and select the root of your Erlang/OTP install (mine is /opt/local/lib/erlang), then click OK (dialog will close)
- Click OK (preferences dialog will close)
- (wait for Eclipse to restart) Select Window (menu) -> Close All Perspectives
- Select Window (menu) -> Open Perspective -> Other... (a dialog will appear)
- Select Erlang and click OK (dialog will close and Erlang Perspective will load)
- In the Erlang Navigator bring up the context menu (right-click/control- click) and select New Erlang Project (a dialog will appear)
- Enter hello_world in the Project Name field and click Finish (dialog will close and hello_world project will appear in Erlang Navigator view)
- Select hello_world project, bring up the context menu and select Run As -> Run Configurations... (a dialog will appear)
- Enter
hello_worldin the Name field - Double-click Erlang application (a new confguration will appear in the right-hand panel)
- In the Main tab under Projects click the checkbox beside hello_world
- In the Runtimes tab click the checkbox beside Start the Erlang node if
not running already and enter
hello_worldin the Node name field. - In some environments, the cookie value needs to be specified (because Java and Erlang don't find the same default cookie).
- Click Run (dialog will close and Console will appear with hello_world Erlang node)
- Leave the Console running for the next part
- On the hello_world project bring up the context menu (right-click /control-click) and select New Module (dialog will appear)
- Enter
hello_worldin Module name field - To the left of the Apply button, enter
say_helloin the first box and0in the second box and click Apply - Click Finish (dialog will close and an editor for
hello_world.erlwill be opened) - In the Console type
hello_world:say_hello(). - Oops! It displays ok and shows no greeting! Let's fix that
- In the hello_world.erl editor replace
okin say_hello withio:format("Hello World!")and save (Ctrl+S or Command+S) - In the Console type
hello_world:say_hello(). - Great! It displays "Hello World!" for us! Let's get it to say something else
- In the hello_world.erl editor replace
"Hello World!"in say_hello with"Hello ErlIDE!") and save (Ctrl+S or Command+S) - In the Console type
hello_world:say_hello(). - Nifty! It displays
"Hello ErlIDE!"for us! We can change the code at runtime.