Running Julia .jl files

荒凉一梦 提交于 2019-12-03 02:34:32

问题


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>"


回答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.




回答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




回答3:


Look into using IJulia w/in Jupyter Notebook: https://github.com/JuliaLang/IJulia.jl




回答4:


You also can use IntelliJ IDEA with the plugin of Julia ... That's a surprise




回答5:


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.



来源:https://stackoverflow.com/questions/22240581/running-julia-jl-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!