Ask coding questions

← Back to all posts
Import code files to repl
PaulLeger (15)

Hi, I am professor and want to import source code files (C++'s examples) and later share with my students, Is it possible?

Answered by 21natzil (1205) [earned 5 cycles]
View Answer
21natzil (1205)

You can upload files from your computer into a repl, and then have your students fork the repl, so each receives the same copy.

PaulLeger (15)

@21natzil Thanks ... I found the way!

HasanGonen (0)

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.undo.UndoManager;

public class UndoDemo extends JFrame {

private UndoManager undo = new UndoManager();
private JTextArea textArea = new JTextArea();

public UndoDemo() {

    super("Undo  Redo");
    LinkedList<String> cars = new LinkedList<String>();
    Container cp = getContentPane();
    cp.add(textArea = new JTextArea(10, 30), BorderLayout.CENTER);
    JPanel bp;
    cp.add(bp = new JPanel(), BorderLayout.SOUTH);

    undo = new UndoManager();
    JButton undoButton;
    bp.add(undoButton = new JButton("UNDO"));
    undoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (undo.canUndo()) {
            } else {
                warn("Geri alinamaz");

    JButton redoButton;
    bp.add(redoButton = new JButton("REDO"));
    redoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (undo.canRedo()) {
            } else {
                warn("Ileri alinamaz");

void warn(String msg) {
    JOptionPane.showMessageDialog(this, "ERROR: " + msg, "ERROR",

public static void main(String[] files) {


    new UndoDemo().setVisible(true);



leon332157 (341)

You can create a new repl and upload your code to it.

PaulLeger (15)

@leon332157 But, I have around 35 files because during a semester I teach many pieces of code. It is possible to upload a batch of sources code?

Mosrod (552)

@PaulLeger Yes, you can upload a folder of source code, and make your students fork that repl in the beginning of a semester, and they will have one repl for the whole semester with all of their files.

PaulLeger (15)

@Mosrod Yes, it is very useful!!!

Following this method, I have many files and want to compile/execute in an isolated way. Is it possible?

Mosrod (552)

@PaulLeger I don't think so, might add it in the future, but for now, you can rename the file that you want to run to ''.

Mitchelle_RR (3)

@Mosrod I don't see that option to add folders!! I don't know why.