Running Julia .jl files
Solution 1
If you want to run the julia script from a command line then just do
/path/to/julia script-name.jl
In the shell of your choice.
If you want to run it from the julia repl then you want something like so:
julia> include("path/to/script-name.jl")
As to why your output is split like that I think we would need to see your code.
Solution 2
You can chmod your script and put the path to the julia binary at the to line.
Consider the following simple script hello.jl
#!/usr/bin/julia
println("Hello world")
change permission on the script using
chmod a+x hello.jl
Run the script using ./hello.jl
Solution 3
Look into using IJulia w/in Jupyter Notebook: https://github.com/JuliaLang/IJulia.jl
Solution 4
step 1: Open terminal
step 2: go to your Julia file location
step 3: execute the julia file
/path/to/folder script-julia.jl
Hit the up arrow, if it helps you. Thank you.
Related videos on Youtube
user1748681
Updated on December 18, 2021Comments
-
user1748681 over 2 years
I'm new to julia and just finished my first program. I wrote the code in julia-studio and have been testing it within that program. It gives me all of the correct output, but the shell separates the output as if it is two different executions.
I'm wondering if it's a problem with my compiler, so I thought I would try compiling it in the default julia shell found at julialang.org.
However, I cannot understand and/or figure out how to run it there. My current program reads input from another file in the same directory and outputs the results.
Can anyone explain how to run the program. This http://julia.readthedocs.org/en/latest/manual/getting-started/ isn't making sense to me.
Example output:
julia> program # # # # julia> # # # # #
The # represents integer numbers. Ideally the output should not be seperated by "julia>"
-
user1748681 about 10 yearsThanks, this helped a lot. Well, it helped me realize I wasn't crazy. It appears I had downloaded the "prerelease" version of Julia 0.3. I downloaded an earlier version and used the julia.bat as the default program. Command prompt displayed all of the output correctly.
-
beOn over 8 yearsNot really an answer to the question, but a helpful suggestion nonetheless if user1748681 hasn't tried it yet.
-
Pragyaditya Das about 8 yearsHow do I add julia to path? I cannot even find the installation file in my C drive?
-
nightcod3r over 7 years0.5.0 version seems to store it somewhere else:
bash: ./hello.jl: /usr/bin/julia: bad interpreter: No such file or directory
, any idea of where to find it? -
Sebastian Good over 7 yearsOn OS X if you use the built-in installer, it's at
/Applications/Julia-0.5.app/Contents/Resources/julia/bin/julia
. Best is indeed to make a soft link to the binary. -
Dima Mironov almost 7 yearsIt's better to use
#!/usr/bin/env julia
to avoid problems with the exact julia location -
djangofan over 5 yearsWas too hard to find such a simple answer.
-
AVA about 5 yearsjulia1.1 on centos7. I tried as suggested. Path has entry /opt/julia/julia-1.1.0/bin/julia. Invoking Julia at terminal brings Julia prompt. Test.jl content: line1:#! /opt/julia/julia-1.1.0/bin/julia line2:println ("terminal invoke test"). Changed permission chmod +x /root/Test.jl #julia /root/Test.jl prints the line. But, #. /root/Test.jl is interpreted as shell script. Please guide me in resolving the issue!
-
AVA about 5 yearsRemoving dot (.) at start of command resolves the issue of treating as shell script.
-
godines about 4 yearsIs there a trick to run 'julia' in the background and save the log file? I've tried to run a .jl script on 'shell' using
nohup
, but the file 'nohup.out' is just empty. Thanks -
NMech over 3 yearsin windows you just need to add the julia.exe path to the PATH variable, and it can be just julia script-name.jl
-
FireFlower over 2 yearsBtw I use Windows OS so it may not work if you have Linux or MacOS