This post is about how to install Julia and run source code files in Windows. Once we install it, we need to configure it a bit to make the Julia executable file available in command-line windows.
Download And Install Julia
Julia has two types of release – current stable and LTS. The current version is 1.4.0. We can download binaries built for Windows, macOS, Generic Linux, and FreeBSD.
For this post, choose current stable – either Windows 32-bit or 64-bit – to download. Run the installer, and the following window will appear. Then, click Install. Wait until the installation completes.
Skip Run Julia and Click Finish.
Run Julia Source Codes In Windows
After we installed julia, we need to configure it a bit to be able to run source code files. Otherwise, we get an error, as shown below,
1 | C:\Users\user123\Desktop\julia-codes\julia |
we get the following error.
1 2 | 'julia' is not recognized as an internal or external command, operable program or batch file. |
This means the path to the julia.exe is not found in the environment variable PATH.
There are two ways to fix this in Windows 10. After this, we can run Julia source code files in any command-line window.
Option 1
This option may need to restart Windows.
- Go to Control Panel
- Go to System And Security
- Go to System
- Go to Advanced system settings
- Click Environment Variables
- Click System Variables
- Look for the PATH variable and select it
- Update the value of PATH by appending the path to ;C:\Users\user123\AppData\Local\Programs\Julia\Julia-1.4.0\bin.
Option 2
For this option, we need to do this when we open a new command-line window. First, run the following command.
1 | set PATH=%PATH%;C:\Users\user123\AppData\Local\Programs\Julia\Julia-1.4.0\bin |
Then, we can now use the julia command. The output is something like the following.
Run Julia Source Code File
Now, it is time to run Julia source code files. We have two identical files, but they only differ in the file name extension. All files are in C:\Users\user123\Desktop\julia-codes.
1 2 | hello-word.any-ext hello-word.julia |
To run each file, use either one of the following commands in the command-line window.
1 2 | C:\Users\user123\Desktop\julia-codes>julia hello-word.any-ext Hello world from turreta.com! |
1 2 | C:\Users\sang018\Desktop\julia-codes>julia hello-word.julia Hello world from turreta.com! |
As we can see, the source code files do not know have specific file extensions.