10

I installed jEdit on my new mac (Intel processor 11.3.1 Big Sur) but it gives me the message

"This application requires that java 11 or later be installed on your computer."

"This application requires that java 11 or later be installed on your computer."

So I installed java with brew install java and followed the instructions to symlink it, and add it to my .zsh PATH. All looks good for java in the terminal:

java --version
openjdk 16.0.2 2021-07-20
OpenJDK Runtime Environment Homebrew (build 16.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 16.0.2+0, mixed mode, sharing)

...but how can I tell the jEdit application where my JRE is.

I tried installing jedit via homebrew too, but the result was the same.

If I run the jar file at the command line then jedit does start up, albeit with these errors showing up in the terminal (significant? maybe not):

% /usr/local/opt/openjdk/bin/java -jar /Applications/jEdit.app/Contents/Java/jedit.jar
12:39:14 [AWT-EventQueue-0] [error] OSXAdapter: Could not talk to EAWT:
12:39:14 [AWT-EventQueue-0] [error] OSXAdapter: java.lang.IllegalAccessException: class macosx.OSXAdapter cannot access class com.apple.eawt.Application (in module java.desktop) because module java.desktop does not export com.apple.eawt to unnamed module @1ed7437b
...
2021-10-13 12:39:15.678 java[44580:3291018] JavaNativeFoundation: GetGlobalVM: Failed to locate @rpath/libjvm.dylib for JNI_GetCreatedJavaVMs(). A JVM must be loaded before calling this function.

So that's a workaround, but I kinda want to be able to click on the application icon!

5
  • What does /usr/libexec/java_home -V return?
    – grg
    Commented Sep 2, 2021 at 18:34
  • 16.0.2 (x86_64) "Homebrew" - "OpenJDK 16.0.2" /usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home
    – Harry Wood
    Commented Sep 3, 2021 at 8:43
  • What does /usr/bin/java --version return
    – mmmmmm
    Commented Sep 24, 2021 at 20:01
  • /usr/bin/java --version returns the same as java --version (posted ^)
    – Harry Wood
    Commented Sep 26, 2021 at 14:10
  • I would note that the build is from Sep 2020 and so predates Apple Silicon and so is Intel only - also com.apple.eawt implies Apple supplied classes - which would be Java 6 - I suspect jEdit is just not well maintained on macOS - report these issues to the jEdit bug tracker but seeing mailing list posting dates don't hold out too much hope
    – mmmmmm
    Commented Oct 13, 2021 at 12:15

6 Answers 6

5

I just installed version 5.6 on a M1 Mac running Monterey. Using this approach allows it to access files in your Downloads folder.

  1. Install the ARM version of Java 17 from Oracle
  2. Install jEdit 5.6 (Follow instructions to drag and drop to your Applications folder and Ctrl-Click it).
  3. Download the precompiled binary of universalJavaApplicationStub
  4. Unzip it, and overwrite the binary /Applications/jEdit.app/Contents/MacOS/jedit with it i.e
    cp ~/Downloads/universalJavaApplicationStub /Applications/jEdit.app/Contents/MacOS/jedit
    
  5. Update the key JVMVersion in /Applications/jEdit.app/Contents/Info.plist using an editor like TextEdit to be 17.
    <key>JVMVersion</key>
    <string>17</string>
    
  6. Launch jEdit

Special thanks to Kohei Nozaki for the idea

4
  • 1
    Perpil's solution worked for me. I just need to change the JVM version to 18 which is the latest one.
    – Brook DJ
    Commented Apr 22, 2022 at 13:27
  • 1
    Worked fine for me as well, I just had to change the version to 19 for my install. Important Note: The universalJavaApplicationStub project is sunsetting.
    – CyberSkull
    Commented Feb 15, 2023 at 12:57
  • This indeed works – thanks a lot! However, while jEdit will correctly trigger the dialog box for access to the Downloads and Documents folders, cloud storage folders do not work (such as OneDrive folders stored under ~/Library/CloudStorage). In the Files and folder settings, only places that each app has asked for can be controlled, so it is not possible to add access that way either. Of course, giving jEdit full disk access is a possible workaround, though not ideal.
    – Otto G
    Commented Mar 23, 2023 at 15:39
  • For me, on an M2 Mac, this works with OpenJDK 19.0.2, but not with 20.0.1, unfortunately.
    – Otto G
    Commented May 17, 2023 at 14:29
1

Mac applications have an info.plist file inside them, where you can sometimes poke in sneaky settings.

You can browse to this by right clicking and saying "Show package contents". You should see a "Contents" directory, and be able to edit an "info.plist" file.

What sneaky settings? Well I got enough clues from this jedit forum post.

First we need to create a symlink from Plugins (also in the "Contents" directory) through to where our JDK is installed. In my case I wanted it to use my homebrew installed JDK, so I needed to do...

cd /Applications/jEdit.app/Contents/PlugIns

ln -s /usr/local/opt/openjdk/libexec/openjdk.jdk openjdk

(Creates a symlink called "openjdk")

Having done that, we can add an entry in info.plist looking like this:

        <key>JVMRuntime</key>
        <string>openjdk</string>

It probably doesn't matter where in the file. I put these two lines above <key>JVMOptions</key>

Having done that, I can now click the jedit icon in Applications, to start it up!

1
  • This solution gets gEdit working but doesn't solve the overall Java misconfiguration.
    – djangofan
    Commented Nov 8, 2021 at 20:06
0

I installed Java 11 and jEdit via homebrew on MacOS Big Sur. For me, this works to start jEdit afterwards:

/usr/local/opt/openjdk@11/bin/java -jar /Applications/jEdit.app/Contents/Java/jedit.jar 2> /dev/null &

You can of course simplify this by adding the java 11 binary to your path, by setting aliases or writing a little shell script wrapper, but this is what's gonna work out of the box.

4
  • Won't just using java rather than the full path work - as the OP shows java --version works
    – mmmmmm
    Commented Oct 13, 2021 at 10:56
  • Absolutely, if you have added this particular java version to your path. Brew even suggests this when you install java 11 via brew, but I didn't want to assume that everyone who stumble across this HAS done so, and as I said in my answer, that long command line is going to work in either case.
    – Thor
    Commented Oct 13, 2021 at 11:05
  • The question says they have - So you MUST assume that., Anyway the question I think is how to be able to open the application and not run from the command line
    – mmmmmm
    Commented Oct 13, 2021 at 11:06
  • That's useful though, because I couldn't work out the way to run the jar from the command line. Doing so is an ugly workaround, but it does start up jedit. It also shows some other errors which I'll add to my question (I guess it's possible those issues might cause the error pop up. It would be an unhelpful message if that was the case, but maybe).
    – Harry Wood
    Commented Oct 13, 2021 at 12:00
0

Just for information, as posted solution with Info.plist, works great for me!

Anyway, I was looking for something that acted globally, like a config or setting (sneaky too :-)), who let open any UI Java App without giving error message:
"This application requires that java 11 or later be installed on your computer."


Environment is:

  • MBA (Intel) with Big Sur 11.6.1
  • Homebrew with openjdk and jEnv (macos-javahome)

1. Using jEnv command 'macos-javahome'

Purpose was to try jEnv command:

$ jenv macos-javahome

as it should (conditional is mandatory) set JAVA_HOME for all GUI Applications through launchctl setenv, as stated here:

# Usage: jenv macos-javahome
#
# Installs a file located at ~/Library/LaunchAgents/jenv-environment.plist . It sets JAVA_HOME for GUI
# applications on startup for the **currently active version of Java**.

First thing, in Big Sur 11.6.1, there is no ~/Library/LaunchAgents folder under my profile directory.
I created it anyway, with right perms just to go further with jEnv and apply all changes and restart everything you need.

The final result that is this setting through jEnv is completely ignored by UI Java Apps, and still get error:
"This application requires that java 11 or later be installed on your computer."

==> This way with jEnv and Big Sur 11.6.1 don't work.


2. Modifying OpenJDK to run Java applications

Purpose was to modify OpenJDK's Info.plist adding BundledApp capability, as pointed here and here.

In brief, in my environment, modify the file /Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Info.plist from this

<key>JavaVM</key>
  <dict>
    <key>JVMCapabilities</key>
      <array>
        <string>CommandLine</string>
      </array> ...

to this

<key>JavaVM</key>
  <dict>
    <key>JVMCapabilities</key>
      <array>
        <string>BundledApp</string>
        <string>CommandLine</string>
        <string>JNI</string>
      </array> ...

==> Also this way with a modified OpenJDK's Info.plist and Big Sur 11.6.1 don't work.

Results

After trying, both ways don't work at the moment in my environment with Big Sur 11.6.1.

That one with jEnv don't work in opposition to what jEnv macos-javahome command says. Here it also seems that Java UI Apps completely ignore JAVA_HOME environment variable, whether it is set through shell (ex. zsh) or jEnv macos-javahome.

That one with OpenJDK modification, apparently jEdit App isn't looking for those JVM capabilities in OpenJDK's Contents/Info.plist.

1
  • There is no global way - either app by app to allow different versions to be used - this is the approved Apple way - or run java from the command line as is the normal non macOS way
    – mmmmmm
    Commented Dec 2, 2021 at 21:49
0

None of the above solutions seem to work with latest install of Ventura 13.6.2, OpenJDK 21 and Jedit 5.6 on my '23 M2 MacBook Pro. I was able to get it working by editing the jEdit info.plist on a previous OS & JDK version combo on my older '21 M1, but that's just not working for me on this new system. Ultimately I gave up and just crafted the following very simple solution which should work for anyone:

#!/usr/bin/env bash

jvmOptions='-Dapple.awt.textantialiasing=true -Dapple.laf.useScreenMenuBar=true -Dapple.awt.antialiasing=true'
jvmXOptions='-Xdock:name=jEdit -Xdock:icon=/Applications/jEdit.app/Contents/Resources/icon.icns'

export JAVA_HOME=$(/usr/libexec/java_home)

# To force MacOS to show 'jEdit' as the Dock name we use a symlink to invoke the java process.
# I.E., "~/Library/jEdit/jvm/jEdit" is a symlink --> /Library/Java/..../bin/java".   This link needs to change if the JDK install changes so we rebuild it each time.
mkdir -p ~/Library/jEdit/jvm
rm -f ~/Library/jEdit/jvm/jEdit
ln -s "$(/usr/libexec/java_home)/bin/java" ~/Library/jEdit/jvm/jEdit
~/Library/jEdit/jvm/jEdit $jvmXOptions $jvmOptions -jar /Applications/jEdit.app/Contents/Java/jedit.jar -reuseview $@ 2> /dev/null > /dev/null  &

Prep: This requires that Java 11+ be installed and that the command

$ /usr/libexec/java_home

returns the 'JAVA_HOME' directory.

The script does a little trick where it creates a symlink to the current 'java' executable in the ~/Library/jEdit/jvm/ directory with the name 'jEdit' and uses THAT to launch the JVM. The reason we do this is so that Mac OS sees the process name as 'jEdit' and displays that above the Dock icon, as the current "-Xdock:name" parameter behavior doesn't set that correctly. It does correct the name in the menu bar so we still want that X parameter set. The creation/deletion of this symlink under the path "~/Library/jEdit/jvm/" means it is in user-space and shouldn't trip on anything.

The above script just needs to have it's executable bit set and then it can be executed from anywhere, but for full integration it can be just dropped right in place of the (imho broken) Jedit executable at:

/Application/jEdit.app/Contents/MacOS/jedit

If you just replace that file with the above script, and set the executable bit:

$ sudo chmod a+x /Application/jEdit.app/Contents/MacOS/jedit

it should 'just work' exactly as the original executable is supposed to.

The resetting of the ~/Library/jEdit/jvm/jEdit symlink each time you launch means that if you install a new Java version this should automatically use that.

If you install a new version of jEdit, this script would get wiped out so make sure you save a copy off to the side.

The above technique can obviously be adapted to fix the launch of other Java apps that might trip on this issue.

-1

My opinion and an indirect solution. jEdit is just searching your path for the java11 binary. I am a Java developer since 1996.

brew install java didn't work so well for you did it? I prefer not to do it that way because of issues like this.

Having Java at /usr/local/opt is wrong.

Java JDK should be at /Library/Java/JavaVirtualMachines . I usually either manually download JDK and unzip it into the above folder OR install it via jenv command. The former gives you more control.

Then you should have JENV installed and have this in your .bash_profile :

export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"

Don't install Java with brew . Instead: brew install jenv . Then, install Java (OR link to your installed java) using JENV.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .