Run Code Online: Sandbox Limits for Python, JS, Java, Go, C++
When you have no compiler at hand and will not install a whole toolchain for ten lines of code, an online runner is the fastest way to check an idea. Just know the boundaries first: it runs in a throwaway sandbox with no network and no persistent files.
- Online runners suit syntax checks, small algorithms and reproducible snippets - not long jobs, network calls, persistent files or third-party packages
- Every run starts a throwaway isolated container with its own filesystem and resource caps, and the container is destroyed when the run ends
- Python and JavaScript execute in your browser and never upload code; Java, Go, C++ and Shell are compiled and run by a self-hosted execution gateway
- A sandbox protects your machine from the code, it does not keep the code secret, so never paste company source, keys, tokens or customer data
- Failures fall into five buckets - compile errors, timeouts, resource limits, missing dependencies and encoding - and each one needs a different fix
- Entry conventions differ per language: Java needs a matching class name, Go needs package main, C++ needs the right headers, Shell has no interactive terminal
#What online runners are actually good for
Online runners are good at exactly three things: checking whether a snippet compiles, testing a small algorithm, and sharing a reproducible example. Anything longer than about 20 lines usually belongs in a local environment.
These cases pay off the most:
- Learning a language and testing one construct: a list comprehension, a slice, a pointer, a closure
- Running boundary cases of an algorithm before you copy it back to your editor
- Working on someone else's machine where nothing is installed
- Sending a colleague a bug reproduction they can run in one click
Python Runner executes in your browser through Pyodide. The first run loads the runtime and takes about 10-30 seconds; after that it is instant, and Ctrl+Enter runs your code. JavaScript Runner also runs locally in the browser with live console.log and async/await support.
#What container isolation means
Isolation means your code does not run on your machine or on a shared box - each request starts a sandbox container that is destroyed as soon as the run ends. It gets its own filesystem, its own process space and hard resource caps.
Four practical consequences follow:
- Files you write exist only for that run; the next run sees a clean container
- Nothing you install or export survives into the next execution
- Wall time, memory and process count are capped, and a process that exceeds them is killed
- The execution container has networking disabled, so pip install, go get and npm install all fail
A sandbox protects your machine from the code. It does not keep the code confidential. Never paste company source, private keys, tokens or real customer data into any online execution service.
Java, Go, C++ and Shell are handled by a self-hosted execution gateway. It listens on a local port only, accepts requests from this site's pages only, and runs each submission in a fresh isolated container.
If that gateway is unavailable, the page falls back to a third-party execution service, and your code leaves this site.
To tell whether code leaves your computer, look at the language: Python and JavaScript run inside the browser and are never uploaded, while the other four are sent to the execution gateway.
#Java, Go, C++ and Shell each fail differently
Most failures in compiled languages are about the entry point, not the logic: Java looks for a class name, Go looks for package main, C++ needs its headers. Get those aligned and you remove half the errors.
| Language | How it runs | Where people get stuck |
|---|---|---|
| Java Runner | Compiled, then executed; standard input supported | Leave the entry class non-public, or name it Main |
| Go Runner | Compiled, then executed | Needs package main and func main, and every import must be used |
| C++ Runner | Compiled by the backend with a fixed standard | Forgetting an #include; there is no field for compiler flags |
| Shell Runner | Bash script executed directly | No interactive terminal, no sudo, background jobs die with the container |
#Java: the class name has to match the entry file
Java requires a public class to live in a file of the same name. The entry filename in the sandbox is fixed, so the easy fix is to drop public or simply call the class Main.
// Fails: a public class must match the entry file name
public class Test {
public static void main(String[] args) {
System.out.println("hello");
}
}// Works: no public modifier, so the fixed entry file accepts it
class Main {
public static void main(String[] args) {
System.out.println("hello");
}
}#Go: package main and unused imports
A Go program runs only if it declares package main with a func main. On top of that, every imported package must be used, or compilation stops immediately.
// Fails: no package declaration at the top of the file
import "fmt"
func main() {
fmt.Println("hello")
}// Works: complete entry declaration
package main
import "fmt"
func main() {
fmt.Println("hello")
}#C++ and Shell
C++ needs an explicit #include for every symbol you use, and the compiler standard is fixed on the backend - there is no -std or -O switch in the interface, so code that needs a newer standard may not build.
Shell has no interactive terminal, so a script has to run to completion unattended. Anything needing a system service or administrator rights simply is not available.
#What online runners cannot do
Four jobs do not belong in an online runner: long computations, network access, persistent files and third-party packages. These are not configuration gaps - the sandbox is designed without them.
| What you want | Why it fails online | Do this instead |
|---|---|---|
| A training job or batch run of several minutes | The run time limit terminates the process | Use a local machine or a server |
| Calling an API or downloading data | The execution container has networking disabled | Run locally, or test the logic against data you already have |
| Keeping an output file for later | The container is destroyed when the run ends | Write files on your own machine |
| pandas, requests, numpy and friends | The sandbox cannot install packages | Rewrite with the standard library, or run locally |
| Real production data | Your code is sent to an execution service | Replace it with fake data first |
#Read the error: sort it into one of five buckets
Almost every online failure is a compile error, a timeout, a resource limit, a missing dependency or an encoding problem - and the fix is different for each.
| Symptom | Cause | Fix |
|---|---|---|
| Timed out, process stopped | Infinite loop, recursion with no base case, or the program is waiting for input | Check loop exits; put interactive input in the stdin box before running |
| Process killed, memory error | One huge allocation, or a collection growing without bound | Shrink the data to a few thousand rows, validate the logic, then scale up |
| 'xxx' was not declared / cannot find symbol | Missing header, missing import, or a class name that does not match the entry | Add the declarations listed in the language table above |
| ModuleNotFoundError / cannot find package | The library is not in the sandbox and cannot be installed | Rewrite with the standard library, or move to a local machine |
| A compile error pointing at line 1 that makes no sense | Invisible characters from pasting, or the wrong language selected | Clear the editor, paste again, and check the language dropdown |
| Output shows question marks or boxes | Output is not UTF-8 | Emit UTF-8 explicitly instead of relying on a locale default |
| Runs fine but prints nothing | The program ended without printing, or wrote only to the error stream | Print one line first to confirm it executed, then check the output calls |
A program that never finishes is usually not stuck in a loop - it is waiting on the keyboard. There is no interactive terminal, so all standard input must be supplied before you press Run.
#Which tool for which job
| What you need | Tool | Notes |
|---|---|---|
| Pull fields out of program output or logs | Regex Tester | Handy for parsing and format checks |
| Compare two runs character by character | Text Diff | Much faster than eyeballing output |
| Check a schedule expression before scripting | Cron Generator | Validate the five fields first |
| Validate JSON before pasting it as stdin | JSON Formatter | Catch bad structure before a confusing runtime error |
| Decode something you copied from a log | Base64 Encode/Decode | Turn it back into readable text first |
#Frequently asked questions
#Is it safe to run code online? Can I paste company code?
No. A sandbox keeps the code from touching your machine; it does not make the code confidential. Java, Go, C++ and Shell submissions are sent to the execution gateway, and fall back to a third-party service if the gateway is down. Python and JavaScript stay in your browser, but the same advice applies: no keys, no tokens, no real data. When you need to reproduce production logic, replace the sensitive parts with fake values.
#Why is the first Python run so slow?
Because the runtime loads in your browser. Pyodide downloads and initialises the runtime on the first run, which takes roughly 10-30 seconds, and every run afterwards returns in about a second. If it is slow every single time, check whether your browser is caching the runtime files.
#Can I install pip or npm packages in the sandbox?
No. The execution container has networking disabled, so installers and downloads fail. Code that depends on a third-party library either needs a standard-library rewrite or a local machine.
#Java keeps complaining that the class name does not match the file. What do I change?
Drop the public modifier on the entry class, or rename the class to Main. A public class must match its filename, and the sandbox uses a fixed entry filename, so removing public is the simplest fix.
#The program hangs and never prints anything. Where is it stuck?
Check input first. An online runner has no interactive terminal, so a program blocking on standard input simply waits until data appears in the stdin box. If input is not the cause, look at loop exits and recursion base cases. Both problems look identical from the outside: nothing is printed until the time limit kills the process.
Tools used in this guide
Run Python 3 in browser with Pyodide, no install
Open tool →JavaScript RunnerRun JavaScript in the browser locally, console output and async/await support…
Open tool →Java RunnerCompile and run Java with JDK 21, supports stdin and class examples
Open tool →Go RunnerCompile and run Go 1.22, supports stdin, slices and structs
Open tool →C++ RunnerCompile and run C++ with GCC 13
Open tool →Shell RunnerExecute Bash scripts online
Open tool →