简体   繁体   中英

Erlang cannot run in intellij

Trying to run simple erlang file in intellij.

-module('Tutorial').

%% API
-export([helloWorld/0]).

helloWorld() -> io:write("Hello World").

But when I try to run I always get

init terminating in do_boot ()

{"init terminating in do_boot",{{unbound_var,'Tutorial'},[{erl_eval,exprs,2,[]}]}}
Crash dump is being written to: erl_crash.dump...done

Im using erlang 8.3 and a intellij plugin for erlang.

Use:

-module('tutorial').

in a file called: "tutorial.erl". The expression: "Tutorial" is interpreted as a variable (because the first letter is capitalized). When the runtime encounters this variable, it tries to evaulate it, but since it is not defined, you get the error.

Sort of- atoms (which module names are) can be capitalized if surrounded by single quotes, as seen here. I'm not sure how you're running the code, but the following illustrates (the code is in Foo.erl).

-module('Foo').

-export([bar/0]).

bar() ->
  io:format("foobar~n").

And then

1> c("Foo.erl").
{ok,'Foo'}
2> 'Foo':bar().
foobar
ok
3> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM