Configuring the RUN button (Java and Python Examples)
MrMazzone (11)

This tutorial will help you configure the RUN button in your 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:

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"

Example .replit file

run = "bash"

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.

javac *.java
java HelloWorld

More info here if you want to learn the basics of javac:

Python Code

For a Python project, you need to use the python or python3 command to execute a python file. Simple type the file name after the python command.


More info here if you want to learn the basics of python command line:

See example 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.

You are viewing a single comment. View All