Skip to content

Run Java Code

Use the runCode/run_code method to run Java code inside the sandbox. Pass the language parameter with value java.

JavaScript/TypeScript Example:

javascript
import { Sandbox } from '@e2b/code-interpreter'

const sbx = await Sandbox.create()
const execution = await sbx.runCode('System.out.println("Hello, world!");', { language: 'java' })
console.log(execution)

Python Example:

python
from e2b_code_interpreter import Sandbox

sbx = Sandbox.create()
execution = sbx.run_code('System.out.println("Hello, world!");', language='java')
print(execution)

E2B Documentation • Generated from e2b.dev/docs