Skip to content

Latest commit

 

History

History
86 lines (68 loc) · 2.58 KB

File metadata and controls

86 lines (68 loc) · 2.58 KB

Java Support Added to Prismo Code Editor

Summary

Java compilation and execution support has been successfully added to both the backend and frontend.

Changes Made

Backend (backend/app/claude_routes.py)

  1. ✅ Added execute_java_code() function that:

    • Extracts the public class name from Java code using regex
    • Compiles Java code using javac
    • Executes compiled code using java command
    • Handles compilation errors and runtime errors
    • Cleans up temporary files after execution
  2. ✅ Updated language validation to include "java"

  3. ✅ Updated code execution logic to route Java code to the new executor

  4. ✅ Updated test case runner to support Java

Frontend

CodeMirror Editor (src/components/widgets/coding/code-editor/code-editor.ts)

  1. ✅ Installed @codemirror/lang-java package
  2. ✅ Imported Java language support
  3. ✅ Added Java case in getLanguageSupport() method for syntax highlighting and autocomplete

Monaco Editor (src/components/widgets/coding/editor-panel/editor-panel.ts)

  1. ✅ Updated supported languages list to include 'java'
  2. ✅ Monaco Editor has built-in Java support, no additional configuration needed

Supported Languages

The code editor now supports:

  • ✅ JavaScript/JS
  • ✅ Python/Py
  • ✅ C++/CPP
  • ✅ Java (NEW!)

Requirements

To run Java code, the server must have:

  • Java Development Kit (JDK) installed (includes javac compiler)
  • Java Runtime Environment (JRE) included in JDK

Note: Currently, the server has JRE but not JDK. To enable Java execution:

# Install JDK (example for macOS)
brew install openjdk

# Or download from: https://www.oracle.com/java/technologies/downloads/

Testing

A test script has been created at backend/test_java_execution.py to verify Java execution.

To test:

  1. Ensure JDK is installed: javac -version
  2. Start the backend server
  3. Run: python3 backend/test_java_execution.py

Java Code Examples

Your existing Java modules will now work with the code editor:

  • coding---java-ada94bbc.json
  • coding---java-e5f9cef1.json
  • coding---java-640fda73.json
  • And many more!

Example Java code that can now be executed:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello from Java!");
        int sum = 5 + 10;
        System.out.println("5 + 10 = " + sum);
    }
}

Features

  • ✅ Syntax highlighting for Java
  • ✅ Autocomplete support for Java
  • ✅ Compilation error reporting
  • ✅ Runtime error handling
  • ✅ Test case execution
  • ✅ Execution time tracking
  • ✅ Output capture