User Tools

Site Tools


java-macosx

Java Runtime Environment (JRE) Setup on macOS

This page documents how to install and configure a Java Runtime Environment (JRE) for use with Crossfire-related tools on macOS systems.

Although only a JRE is required to run Java applications, most modern distributions provide a full JDK (Java Development Kit), which includes the JRE.


Why Java is Required

Some Crossfire development and maintenance tools are written in Java and require a working Java runtime to execute.

These tools are typically used for:

  • Map editing and validation utilities
  • Asset or data processing tools
  • Legacy tooling that predates newer client or server utilities

Java is used in these cases because it provides:

  • Cross-platform compatibility (same tools run on Linux, macOS, and Windows)
  • Stable runtime behavior across environments
  • Ease of distribution without requiring platform-specific builds

For most users, Java is not required to play Crossfire, but it may be required if you:

  • Contribute maps or content
  • Run certain developer tools
  • Work with legacy utilities still in use by the project

Supported Platforms

  • Intel-based macOS (x86_64)
  • Apple Silicon macOS (arm64 / M1, M2, M3)

1. Determine System Architecture

Open a terminal and run:

uname -m

Results:

  • x86_64 → Intel Mac
  • arm64 → Apple Silicon Mac

2. Install Java

Option A: Homebrew (Preferred)

Install Homebrew if not already present:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install OpenJDK:

brew install openjdk

Link the installed JDK into the system Java location:

sudo ln -sfn $(brew --prefix openjdk)/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk.jdk

Option B: Manual Installation

1. Download a JDK package (LTS version recommended, e.g. 17 or 21) 2. Select the correct architecture:

  • Intel → x64
  • Apple Silicon → arm64 / aarch64

3. Install using the provided .pkg installer

Installed location:

/Library/Java/JavaVirtualMachines/

3. Environment Configuration

Edit your shell configuration file:

  • zsh (default): ~/.zshrc
  • bash: ~/.bash_profile

Add the following:

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

Apply changes:

source ~/.zshrc

4. Verification

Confirm Java is available:

java -version

Example output:

openjdk version "21"
OpenJDK Runtime Environment
OpenJDK 64-Bit Server VM

5. Notes for Apple Silicon

  • Use native arm64 builds whenever possible
  • Avoid relying on Rosetta 2 unless required for compatibility
  • Homebrew installs the correct architecture automatically

6. Managing Multiple Java Versions

List installed versions:

/usr/libexec/java_home -V

Select a specific version:

export JAVA_HOME=$(/usr/libexec/java_home -v 21)

7. Troubleshooting

Java command not found

Check JAVA_HOME:

echo $JAVA_HOME

If unset:

/usr/libexec/java_home

Incorrect Java version

Ensure the correct version is selected:

/usr/libexec/java_home -V

Then set:

export JAVA_HOME=$(/usr/libexec/java_home -v <version>)

8. Removal

To remove a Java installation:

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-<version>.jdk

Summary

  • Install via Homebrew for simplicity
  • Use architecture-appropriate builds (x86_64 vs arm64)
  • Configure JAVA_HOME for consistent behavior
  • JDK packages include the required JRE
  • Java is primarily needed for Crossfire development tools

java-macosx.txt · Last modified: by leaf

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki