Building CircuitJS1
Development setup and build instructions
Prerequisites
CircuitJS1 is a Java application compiled to JavaScript using Google Web Toolkit (GWT). You’ll need:
- Java 11 JDK
- Apache Ant for building
- GWT SDK (automatically downloaded by dev scripts)
Quick Setup with Dev Container
The easiest way to get started is using the provided development container:
Using GitHub Codespaces or Gitpod
- Fork the circuitjs1 repository
- Open in your preferred cloud development environment
- The container will automatically set up Java, GWT, and other dependencies
Using Local Dev Container
# Clone the repository
git clone https://github.com/johnnewto/circuitjs1.git
cd circuitjs1
# Run the setup script
./dev.sh setup
# Start development servers
./dev.sh startThis will start: - Web server on http://localhost:8000 - GWT code server on http://localhost:9876
Manual Setup
Install Dependencies
On Ubuntu/Debian:
sudo apt-get update
sudo apt-get install openjdk-11-jdk-headless antOn macOS:
brew install openjdk@11 antBuild with Gradle
# Compile GWT application
gradle compileGwt --console verbose --info
# Create deployment directory
gradle makeSite --console verbose --infoThe compiled application will be in the site/ directory.
Build with Ant (Legacy)
# Compile the application
ant build
# The output will be in the war/ directoryDevelopment Workflow
Eclipse Setup
- Install Eclipse for Java Developers
- Add the GWT Plugin for Eclipse
- Import the project
- Use Debug As > GWT Development Mode for live development
VS Code Setup
The repository includes VS Code configuration for development containers:
- Install the Remote-Containers extension
- Open the repository in VS Code
- Click “Reopen in Container” when prompted
- Use the integrated terminal to run build commands
File Structure
The build system works with these key directories:
src/com/lushprojects/circuitjs1/client/ # Java source code
war/ # Web application files
circuitjs.html # Main application page
circuitjs1/ # Generated GWT output
build/ # Gradle build outputs
site/ # Final deployment files
Deployment
Local Testing
After building, you can test locally:
cd site # or war/ for ant builds
python3 -m http.server 8080Then open http://localhost:8080/circuitjs.html
Production Deployment
- Build the application using Gradle or Ant
- Copy all files from
site/(orwar/) to your web server - Exclude the
WEB-INF/directory from deployment - Customize
circuitjs.htmlheader for analytics, favicon, etc. - Optionally customize
iframe.htmlfor branding
Required Files
For deployment, you need: - circuitjs.html - Main application - circuitjs1/ directory - GWT compiled output - Supporting files (CSS, images, etc.)
Troubleshooting
Common Issues
Build fails with Java version errors: - Ensure you’re using Java 8 or later - Set JAVA_HOME environment variable
GWT compilation out of memory: - Increase heap size: export ANT_OPTS="-Xmx2g"
Development mode doesn’t reload: - Clear browser cache - Restart the GWT code server - Check that port 9876 is accessible
Permission denied on dev.sh:
chmod +x dev.shGetting Help
- Check the Contributing Guide for more details
- Browse existing GitHub Issues
- Review the original README
Next Steps
Once you have a working build:
- Try modifying a simple Java file in
src/ - Rebuild and test your changes
- Explore the Contributing Guidelines
- Consider adding new circuit elements or features