I recently started working with Julia from an Ubuntu 20.04 pc (I’m also rather new to linux). I have installed Juliapro, and like working with the Juno GUI.
However, it seems that I can only open it by manually moving to the file where it is installed, open it, and then load the .jl files of interest.
For matlab, the default behavior is similar, but there exists an additional ‘application’ with the same name that
*opens the software from whatever directory when just typing “matlab”
*allows for opening .m files automatically with matlab from Files
(see Defautl to open *.m files in MATLAB, linux - MATLAB Answers - MATLAB Central)
Is there a similar possibility with Julia?
for the first issue, I now managed to put a symbolic link “./Juno” in my home directory as a workaround, but that’s not a very flexible approach
I’m not 100% on what you are trying to do. I also don’t use JuilaPro, so I’m not sure how JuliaPro is different than Julia from a running perspective.
First if you open a standard Ubuntu Terminal can you just type julia to start up Julia? If that works, then you can cd to the directory of your Julia files and run:
julia program.jl
That will start Julia and run your program. If you want something simplier you could create a script (maybe in your home directory or create a bin directory under home) called program.sh with the contents:
#!/bin/bash
julia ~/path/to/julia/file/program.jl
Run “chmod +x program.sh” to mark it as executable, then you should be able to run it by doing:
./program.sh
From that directory. If you need the current directory to be the directory the julia file is in, then this script will probably be better::
#!/bin/bash
cd ~/path/to/julia/file/
julia program.jl
One gotcha is if your program does most of it’s work in an @async block and if you don’t wait for that block Julia will exit when it hits the end of program.jl. Basically something like:
@async begin
x = 1
for i = 1:1_000_000
x = x + i
end
println("Result: $x")
end
Might exit before the println is reached. You would need to do:
task = @async begin
x = 1
for i = 1:1_000_000
x = x + i
end
println("Result: $x")
end
wait(task)
actually, julia doesn’t start when I just type julia
When I do that, I am suggested to install it with sudo apt install julia , but I’m worried that that will interfere with my JuliaPro installation
Likely julia is not in your PATH (the environment variable that tells ubuntu where to look for programs when you enter a name). I think the recommended way is to create a symbolic link for julia in /usr/local/bin. Eg I have the julia tar unpacked in ~/Apps/julia-VERSION and then do something like sudo ln -s ~/Apps/julia-VERSION/bin/julia /usr/local/bin/julia