directory layout
./hello_app.erl
./ebin
./hello.app
code
% hello_app.erl
-module(hello_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
io:fwrite("hello world\n").
stop(_State) ->
ok.
% ebin/hello.app
{application,hello,
[{applications,[kernel,stdlib]},
{mod,{hello_app,[]}},
{modules,[]}]}.
first you need to compile the code
> erlc hello_app.erl
now move the beam file to the ebin directory
> mv hello_app.beam ebin/
load and start the application
> cd ./ebin
> erl
Eshell V6.0
1> application:load(hello).
ok
2> application:loaded_applications().
[{kernel,"ERTS CXC 138 10","3.0"},
{hello,[],[]},
{stdlib,"ERTS CXC 138 10","2.0"}]
3> application:start(hello).
hello world
{error,{bad_return,{{hello_app,start,[normal,[]]},ok}}}
=INFO REPORT==== 17-Apr-2014::00:21:22 ===
application: hello
exited: {bad_return,{{hello_app,start,[normal,[]]},ok}}
type: temporary