Renato Ferreira Renato Ferreira - 4 months ago 7
Linux Question

Cannot run julia file - syntax error close to the unexpected token

Well, i wrote a simple "hello world" in julia, but i cannot figure out on how to run the code. I've tried to run by

./nameOfMyFile.jl
and the terminal returned to me that I have syntax errors.

My code is just:

println("hello world")


Wich works perfectly if i run
julia
on the terminal and write the code after that...

The error is something like( I am translating it from portuguese):

./hello_world.jl: line 1:syntax error close to the unexpected token `"hello world"

./hello_world.jl: line 1: `println("hello world")'


I'm using vim, debian 8 and julia 0.3.2

Answer

Two ways I can think of to achieve what you want

Open a terminal and do either one of the following

Inside the julia relp, that is, if you run julia in the terminal by running

julia

and when you're in, do

include("nameoffile.jl")

if you simple want to run the file, in the terminal do

julia nameoffile.jl