1. Install Erlang,
Ii. Installation
To the http://www.erlang.org/download.html, I downloaded the R15B03-1 windows binary file (91.3 MB), just install it directly. This step is very important to set the path after installation!
Add the Bin (such as c: \ erl5.9.3.1 \ bin) to the path of the system variable (right-click my computer/properties/advanced/environment variables ).
Iii. Check whether Erlang is successfully installed
Open cmd, enter ERL, and press Enter. If the following information is displayed, the installation is successful.
4. Use eclipse
Requirements for Erlang development in eclipse
1. My eclipse is 3.7.2
2. JDK 1.6
3. erlide
OK, install JDK 1.6 first, run the decompressed eclipse (preferably with only the Java version), and then update with the http://erlide.org/update in help/install new software. Select
You can. Restart eclipse after installation. Done!
5. The first Erlang Hello world!
1. Open eclipse, new/project/Erlang Project
Enter the project name "helloworld" and click Finish.
Eclipse automatically creates three folders.
Where:
Ebin stores compiled binary files (with the extension beam)
Include stores the files referenced in the program
SRC stores source code files
2. Right-click SRC and select new module to create an Erlang file (the extension is ERL)
Enter "HW" in Module name ". Note: The name must be in lowercase English or underline. Click Finish
3. Compile the print function
Enter the following code
Printhelloworld ()->
IO: Format ("Hello world! ").
OK. Write printhelloworld to-export to export the function. For example,-Export ([printhelloworld/0]). Here 0 indicates no parameter.
Note: Here-Export ([printhelloworld/0]) should be placed above the function definition;
Note: The function name must be in lower case and in upper case, it must be a variable. The function format is
Method Name (parameter)->
Method body.(Note that the ending point here is the sentence of an English file)
3. Compile
Right-click HW. erl and select Run as/Erlang Application
This will appear in the console
The compilation command is C (file name ).
Enter C (HW). Then press enter to display:
(Helloworld@127.0.0.1) 1> C (HW ).
HW. erl: None: no such file or directory
Error
At this time, an error is prompted: there is no corresponding file.
The directory SRC where HW. erl is located is not identified. So we use the CD command to go to this directory.
(Helloworld@127.0.0.1) 3> Cd ("D:/workspace/helloworld/src ").
D:/workspace/helloworld/src
OK
Note: The Path slash is left to the right;
Then you can compile it.
(Helloworld@127.0.0.1) 4> C (HW ).
{OK, HW}
After compilation, the corresponding HW. Beam file will be generated in the Ebin directory. Run the following command:
HW: printhelloworld ().
Hello world!
OK
OK. The first helloworld program is complete.