This tutorial will help you configure the RUN button in your repl.it project. Specifically, this example shows Python and Java files, but the information can be used to configure the RUN button for other projects.
The .replit file
To configure what the RUN button does in your project, you need to add a .replit file to your project.
In the .replit file you can define run as a string holding a shell command. Whatever shell command run is set to will execute when the RUN button is clicked for the project.
The easiest way to manage complex/multistep commands when the RUN button is clicked is to create a shell script (.sh). The .replit file's run can be set to execute the script by setting it to "bash filename.sh"
Example .replit file
run = "bash run_button.sh"
Java Code
For a Java project you need to compile the project using the javac command. You can either identify a .java file to compile or use *.java to compile all Java files in the folder. Then you can execute the Java class you want by using the java command followed by the class name.
See example repl.it project below which runs a Java and Python run when the RUN button is clicked.
Notice how my example project is actually a Lua project and we are running Python and Java code. For the most part, when you configure the RUN button this way, the project type doesn't matter.
However, if you are creating a graphics or web project, they MUST be set to a graphics project (Python Tkinter, Java Swing, Python Turtle, etc.) or web project (HTML, CSS, JS).
Let me know if you have any questions! I will try to help!
Teachers: When using GitHub classroom, include the .replit file and the shell script in your repo. Teach students how to edit the files if they need to reconfigure the RUN button. Most situations they will not need to change it.
This tutorial will help you configure the RUN button in your repl.it project. Specifically, this example shows Python and Java files, but the information can be used to configure the RUN button for other projects.
The .replit file
To configure what the RUN button does in your project, you need to add a
.replit
file to your project.Read more about the
.replit
file here: https://docs.repl.it/repls/dot-replitIn the
.replit
file you can definerun
as a string holding a shell command. Whatever shell commandrun
is set to will execute when the RUN button is clicked for the project.The easiest way to manage complex/multistep commands when the RUN button is clicked is to create a shell script (
.sh
). The.replit
file'srun
can be set to execute the script by setting it to"bash filename.sh"
Example .replit file
Java Code
For a Java project you need to compile the project using the
javac
command. You can either identify a.java
file to compile or use*.java
to compile all Java files in the folder. Then you can execute the Java class you want by using thejava
command followed by the class name.More info here if you want to learn the basics of
javac
: https://www.dummies.com/programming/java/how-to-use-the-javac-command/Python Code
For a Python project, you need to use the
python
orpython3
command to execute a python file. Simple type the file name after thepython
command.More info here if you want to learn the basics of
python
command line: https://docs.python.org/3/using/cmdline.htmlSee example repl.it project below which runs a Java and Python run when the RUN button is clicked.
Notice how my example project is actually a Lua project and we are running Python and Java code. For the most part, when you configure the RUN button this way, the project type doesn't matter.
However, if you are creating a graphics or web project, they MUST be set to a graphics project (Python Tkinter, Java Swing, Python Turtle, etc.) or web project (HTML, CSS, JS).
Let me know if you have any questions! I will try to help!
An extremely important tutorial.