# Run julia programs like python

**URL:** https://discourse.julialang.org/t/run-julia-programs-like-python/38788
**Category:** New to Julia
**Created:** [May 5, 2020, 7:17am UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788 "2020-05-05T07:17:46Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![catosp](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@catosp](https://discourse.julialang.org/u/catosp)
#### Post date: [May 5, 2020, 7:17am UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/1 "2020-05-05T07:17:46Z")

</div>

Hi there !  
I have a question: In python if I double click on python file then the file run. How can I make this to happen on julia?

Thank you in advance!

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [May 5, 2020, 10:32am UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/2 "2020-05-05T10:32:21Z")

</div>

I guess you mean that in some IDE for Python you can do that. Same with IDEs for Julia. For instance:

- In [Juno](https://junolab.org/), right-click on the file in the project explorer, and select “Juno \> Run all”. More details in [Basic Usage · Juno Documentation](http://docs.junolab.org/latest/man/basic_usage/)
- In the [VSCode extension for Julia](https://github.com/julia-vscode/julia-vscode), right-click on the file and select “Julia: execute file”.

Most IDEs have similar ways to to that.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [May 5, 2020, 11:26am UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/3 "2020-05-05T11:26:01Z")

</div>

On Linux and OS X you could use a [shebang line](https://docs.julialang.org/en/v1/manual/faq/#How-do-I-pass-options-to-julia-using-#!/usr/bin/env?-1) to make the script executable. Mind the startup time, which makes this a rarely used option in Julia for small scripts.

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [May 5, 2020, 12:01pm UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/4 "2020-05-05T12:01:33Z")

</div>

On Windows, at least, you would likely want to register the .jl file-ending, to do something similar, i.e. running it with preinstalled Julia, to what T.Papp suggested (note his way is for CLI, and may not be sufficient for double-clicking, even on non-Windows).++

But **I think you have in mind, running your code without Julia preinstalled** , and without having to do that. Then look into PackageCompiler.jl package, that can make .exe files (I’ve only tried it for Linux). It takes a lot of time to compile, but in the end your program is as fast, even a bit faster since startup-time can be reduced. Currently, the executables are huge however.

If you rather DO use the shebang way (on non-Windows, unless with WSL), then adding it like this at the top of your main Julia file can help:

```julia
#!/bin/bash
#=
exec julia -O1 --color=yes --startup-file=no "${BASH_SOURCE[0]}" "$@"
=#

```

Note, I added the `-O1` to get LESS optimization. It helps to reduce startup time. It depends if it’s faster overall. You could also e.g. add `-p4` or whatever applies to your program (or `-t4` on Julia 1.5) in that (shebang) header, but would have to do those performance options differently, I think, when making a compiled app.

PackageCompiler.jl works with Julia 1.3.x, and latest 1.4 but last time I checked a bug blocked using with (the not yet released) Julia 1.5.

++ I can run my Julia file, like: `./program.jl` but double-clicking on it brings it up in vim editor. I suppose I can change that if I wanted to, but I find it likely you want to configure it to run bash rather than julia (with the “shebang”), unlike on Windows. Note, you may also need to do for `chmod u+x program.jl`

---

<div class="post-metadata">

### Author: ![catosp](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@catosp](https://discourse.julialang.org/u/catosp)
#### Post date: [May 5, 2020, 12:56pm UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/5 "2020-05-05T12:56:02Z")

</div>

Thank you all. Can i run my file.jl with double click, without calling the file.jl from cmd?

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [May 15, 2020, 2:26am UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/6 "2020-05-15T02:26:14Z")

</div>

I don’t use Windows to test this, but I believe this is what you want (if it’s just for you and not to distribute apps):

> **[How to Register a File Type for a New Application - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/shell/how-to-register-a-file-type-for-a-new-application)**
>
> If you plan to associate one or more file types with a new application, you must define a ProgID for each file type that you want to associate with the application.

Here’s how done programmatically (not for Julia but would be similar):

> <https://stackoverflow.com/questions/1720710/register-file-extension-in-window-registry>

But PackageCompiler.jl also works.

---

<div class="post-metadata">

### Author: ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)
#### Post date: [May 18, 2020, 1:07pm UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/7 "2020-05-18T13:07:52Z")

</div>

Right click on file → open with → pick your local julia.exe (which is the REPL)

Should work just fine or did I misunderstand you?

Edit: If you find that your terminal closes too quickly, you might want to insert a `readline()` at the end of your script. This way it will only end and close the REPL when you press enter.

---

<div class="post-metadata">

### Author: ![catosp](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@catosp](https://discourse.julialang.org/u/catosp)
#### Post date: [May 19, 2020, 6:33am UTC](https://discourse.julialang.org/t/run-julia-programs-like-python/38788/8 "2020-05-19T06:33:31Z")

</div>

Thank you! Thats is what i want!
