Skip to content

feat: Add comprehensive Java auto-detection#9

Closed
quinnjr wants to merge 2 commits into
FIUBioRG:masterfrom
quinnjr:feature/java-auto-detection
Closed

feat: Add comprehensive Java auto-detection#9
quinnjr wants to merge 2 commits into
FIUBioRG:masterfrom
quinnjr:feature/java-auto-detection

Conversation

@quinnjr

@quinnjr quinnjr commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Implement robust Java installation auto-detection
  • Enable Java plugin support by default when a JDK is detected
  • Support Linux, macOS, and Windows platforms

Changes

New detect_java_config() Function in build_support.py

Multi-step detection strategy:

  1. Check JAVA_HOME environment variable
  2. Find javac executable and derive JAVA_HOME from it
  3. Search common installation directories by platform:
    • Linux: /usr/lib/jvm/*, /usr/java/*, /opt/java/*
    • macOS: /Library/Java/JavaVirtualMachines/*, Homebrew locations
    • Windows: C:/Program Files/Java/*, Eclipse Adoptium, Microsoft JDK

JavaConfig Class

Holds detection results:

  • java_home: Path to JDK installation
  • include_paths: JNI header directories
  • lib_paths: Library directories
  • libjvm_path: Path to libjvm shared library
  • is_valid: Whether detection succeeded
  • version: Detected Java version

SConstruct Updates

  • Changed --without-java default to False (enable auto-detection)
  • Use detect_java_config() for robust detection
  • Only enable Java features (SWIG wrapper, plugin compilation) if detection succeeds
  • Properly link libjvm

Test plan

  • Test on Linux with OpenJDK installed
  • Test on Linux without Java installed (should gracefully disable)
  • Test with JAVA_HOME set explicitly
  • Test with javac in PATH but no JAVA_HOME
  • Verify Java plugins compile and load correctly

@quinnjr quinnjr force-pushed the feature/java-auto-detection branch from 284ccdf to e3be66a Compare February 3, 2026 22:13
@quinnjr quinnjr force-pushed the feature/java-auto-detection branch from e3be66a to 960595d Compare May 14, 2026 16:04
Replace SConstruct's inline JAVA_HOME/javac probe with a build_support
helper that handles JDK detection across platforms:

  - Check JAVA_HOME env var, fall back to resolving javac on PATH
  - Search platform-specific install paths (Linux/macOS/Windows)
  - Honor RHEL/CentOS /etc/alternatives/java_sdk symlink
  - Match the java-X-openjdk-VERSION dir layout (with arch suffix)
  - When javac resolves to a JRE, walk up to find the matching JDK
  - Configure JNI include paths (jni.h + jni_md.h in platform subdir)
  - Locate libjvm in lib/server (HotSpot) or lib (older layouts)
  - Surface a clear "install <distro>-devel" hint when JNI is missing

The old inline detection in SConstruct hardcoded a RHEL 8 JDK path
and assumed a single layout, so anything outside that exact setup
silently fell back to "no Java." The new detector returns a JavaConfig
dataclass so SConstruct just consults .is_valid / .include_paths /
.lib_paths and registers HAVE_JAVA when the JDK is real.
@quinnjr quinnjr force-pushed the feature/java-auto-detection branch from 9108298 to 285fdcd Compare May 14, 2026 16:21
@quinnjr quinnjr closed this May 14, 2026
@quinnjr quinnjr deleted the feature/java-auto-detection branch May 14, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants