How to open the OptiFine JAR file when double-clicking does nothing
Run java -jar with the exact OptiFine filename from your download folder. If the installer opens, choose Install. A terminal error can point to the file, path or Java version.

If double-clicking the OptiFine JAR opens an archive or does nothing, open a terminal in the download folder and run java -jar "your-file.jar" with the exact filename. If the installer opens, click Install for a standalone Minecraft Launcher setup. If Java prints an error, keep that message and check java -version before changing anything.
For an existing compatible Forge installation, put the intact JAR in that installation's mods folder and start Forge. The installer steps below apply to the standalone route.
Check the download and choose the right route
Use the official OptiFine downloads page and match the full Minecraft: Java Edition version. For Minecraft 1.21.11, the J9 download is OptiFine_1.21.11_HD_U_J9.jar. The same filename on another site tells you nothing about who provided it. When you already play on Forge, use the Forge steps for the matching installation.
On Windows 11, turn on File name extensions under View > Show in Windows File Explorer. This reveals an HTML page or a file ending in .jar.zip that Windows may otherwise shorten in the file list. Return to the official download and use its Mirror link to reach the file page. Changing the extension leaves the file contents as they are.

Check the listed Forge build beside the exact JAR. If it's the one you use, follow the Forge instructions and put the file in that installation's mods folder. The default paths are %APPDATA%\.minecraft\mods on Windows, ~/Library/Application Support/minecraft/mods on macOS and ~/.minecraft/mods on Linux. Open the instance's own folder when a launcher or modpack uses a custom Game Directory.

Prism Launcher separates Add file for Forge from the standalone extraction workflow. Follow Prism's instructions for your instance type. These steps apply to Java Edition. Bedrock Edition can't load an OptiFine JAR.
Open the JAR from a terminal
- Go to your download folder. If the file is in Downloads, enter
cd /d "%USERPROFILE%\Downloads"in Windows Command Prompt orcd "$HOME/Downloads"in macOS Terminal or a Linux shell. - Check Java. Run
java -version. If Windows doesn't recognize the command, your shell reportscommand not found, or macOS can't locate a Java runtime, go to the Java setup below. - Launch the file. Run
java -jar "OptiFine_1.21.11_HD_U_J9.jar", replacing the name inside the quotes with yours. The Java launcher's-jaroption runs the application inside the archive. If the installer opens, check Folder and click Install. Then look for the OptiFine installation in Minecraft Launcher.

Use the first error to choose a fix
- Unable to access jarfile. Check the directory, spelling and quotes. You can also pass the complete quoted path after
java -jar. - Invalid or corrupt jarfile. Check the visible extension and get a fresh copy from the official downloads page.
- UnsupportedClassVersionError. Java reports this error when it can't read a class's version. The installer entry point in 26.1.2 K1 pre2 uses the Java 21 class format (class file version
65.0). The entry point in 1.21.11 J9 uses the Java 8 class format (52.0). Choose a runtime that can read the format named in the error and verify it withjava -version. - No window and no useful error. When you use a preview, try a release for your exact Minecraft version if one is available. The 1.21.9 J7 pre2 report describes a silent exit on Java 17. A player who reported a K1 pre1 failure opened J9 on the same machine. Keep the build name and runtime in any bug report.
Minecraft Launcher can use its own runtime to play the game. Mojang specifies Java 21 for Minecraft 1.21.11 and Java 25 for 26.1.2. Check the terminal's Java separately when the OptiFine installer fails.
If the installer opens and says Minecraft is missing, start the exact vanilla version in Minecraft Launcher, reach the title screen and close the game before trying the installer again.
Set up Java for the terminal
For Windows x64, I'd use Eclipse Temurin's MSI because it can put Java on PATH and associate JAR files with Java applications. Keep both installation features enabled. Pick a package for your own CPU and operating system.
Adoptium documents macOS PKG installation and Linux packages. After installation, reopen the terminal and run java -version. When you have several Java installations, run where java in Windows Command Prompt or command -v java on Linux. On macOS, /usr/libexec/java_home -V lists the runtimes the system recognizes. Run the intended Java executable using its full path in quotes if the terminal selects a different version.
Repair double-click after the command works
On Windows, use Settings > Apps > Default apps, search for .jar and choose the Java handler. If Java isn't offered, repair the association through your runtime's installer. A Windows alternative is the Jarfix utility from its author, which reassigns JAR files to Java.
On macOS, choose File > Open With in Finder and select the Java app if your runtime supplies one. To change the default in Finder, use File > Get Info > Open with > Change All. When no suitable app appears, use the terminal command that worked.
When macOS blocks the download
If Apple can't verify the file, check that you intentionally downloaded it from optifine.net before considering an exception. After the blocked attempt, open System Settings > Privacy & Security as shown in Apple's per-file instructions. Open Anyway may be available for that file in the Security section. For the launcher and desktop Java choices on a Mac, see the macOS setup steps for OptiFine.

