Skip to content

pravsjv/learncoding

Repository files navigation

Java Editor - Electron Setup Guide

Prerequisites

  • Node.js (v18 or higher) - Download from nodejs.org
  • Java Development Kit (JDK) - Download from oracle.com or use OpenJDK
  • Git (optional) - For version control

Quick Start

1. Create Project Directory

mkdir java-editor
cd java-editor

2. Initialize the Project

Create all the files I provided above in your project directory:

  • package.json
  • main.js
  • preload.js
  • index.html
  • styles.css
  • renderer.js

3. Install Dependencies

npm install

4. Verify Java Installation

Make sure Java is properly installed and accessible:

java --version
javac --version

Both commands should return version information.

5. Run the Application

npm start

For development with DevTools:

npm run dev

Key Features Added

✅ Tab Support (4 Spaces)

  • Press Tab to insert 4 spaces
  • Press Shift+Tab to remove 4 spaces
  • Works in both editors

✅ Auto-Matching Parentheses

  • Parentheses: ( automatically adds )
  • Brackets: [ automatically adds ]
  • Braces: { automatically adds }
  • Quotes: " and ' automatically add closing quotes
  • Smart behavior:
    • Wraps selected text when typing opening character
    • Skips closing character if cursor is before matching one
    • Deletes matching pair when backspacing empty pair
    • Auto-indents when pressing Enter between braces

✅ Enhanced Features

  • Theme toggle: Light/Dark mode with persistence
  • Real Java compilation: Uses system javac command
  • Real Java execution: Runs compiled programs
  • Input support: Send input to running programs
  • Timer functionality: Track coding time per pane
  • Error handling: Clear feedback for compilation/runtime errors
  • Modern UI: Clean, professional design with gradients

Testing the Editor

  1. Start the app: npm start
  2. Try the auto-completion:
    public class Test {
        public static void main(String[] args) {
            System.out.println("Hello!");
        }
    }
  3. Test compilation: Click "Compile" button
  4. Test execution: Click "Run" button
  5. Test input: Try a program that reads input:
    import java.util.Scanner;
    public class Input {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.print("Enter your name: ");
            String name = sc.nextLine();
            System.out.println("Hello, " + name + "!");
        }
    }

Next Steps (Phase 2)

  • File save/open functionality
  • Syntax highlighting with Monaco Editor
  • Code folding
  • Find/replace functionality
  • Multiple file tabs

Troubleshooting

Java not found: Make sure Java is installed and in your system PATH Permission errors: On macOS, you might need to allow the app in Security & Privacy settings Compilation fails: Check that your Java syntax is correct and class name matches

Building for Distribution

# Build for current platform
npm run build

# Build for all platforms
npm run dist

The built app will be in the dist folder.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors