Learn to Code via Tutorials on Repl.it!

← Back to all posts
Configuring the RUN button (Java and Python Examples)

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-replit

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

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.

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 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: https://docs.python.org/3/using/cmdline.html

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.


An extremely important tutorial.


Is thare an way of running an HTML, CSS and JS file in an python repl?


@idksolol I don't know a way. However, doesn't mean it is not possible! If you know how to use the shell to setup the HTML file as localhost, there is a possibility the page may render... Try it with a Python Tkinter repl so you have the GUI window.


@MrMazzone thx man ;)


Your share is the great knowledge I have gathered, you are an important person I admire, thank you https://happywheels8.com


@goalkenhighligh thank you!