9

Since there is currently no DrJava application bundle for macOS, I thought I could be the one to make it because I want to use it anyway. From just searching on the internet I made the following application bundle:

- DrJava.app
  - MacOS
    DrJava # this is a shell script that runs java -jar drjava.jar
    drjava.jar
  - Resources
    DrJavaIcon.png
    DrJavaSearchIcon.png
  Info.plist

And my Info.plist looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
  <dict>
      <key>CFBundleName</key>
      <string>DrJava</string>
      <key>CFBundleExecutable</key>
      <string>DrJava</string>
      <key>CFBundleIcon</key>
      <string>DrJavaIcon.png</string>
  </dict>
</plist>

The issue with this is that when I try to run the app, it tells me that I need to install Rosetta to do so.

However, this is simply not true. I can run ./DrJava and it will run perfectly fine without rosetta. My current guess is that there's a key in Info.plist that will indicate the architectures that are compatible with this bundle. But I haven't been able to find any such thing.

PS: Due to personal reasons, I don't want to make an Apple ID. As such I'm not trying to not install Xcode for as long as possible. I understand that this will make things more difficult, but I am committed.

7
  • 2
    Where is java when you run it in the Terminal? Commented Dec 18, 2022 at 11:28
  • 1
    When I run which java it tells me that it's located at /usr/bin/java Commented Dec 18, 2022 at 14:23
  • 1
    Can you show all of the DrJava script Commented Dec 18, 2022 at 14:27
  • 1
    Sure. It's #! /usr/bin/env bash java -jar drjava.jar Commented Dec 18, 2022 at 17:06
  • 1
    WHere is the bash that you use in the terminal? Commented Dec 18, 2022 at 17:41

2 Answers 2

3

This issue seems to occur if you have no ARM format binaries in the MacOS folder. I have found 2 solutions to this bug. One is to just include a ARM binary in the .app/Content/MacOS, even if it does nothing and is used by nothing. You can generate one by running echo 'int main() {return 0;}' | clang -x c -o empty-bin -, and verify it is arm64 by doing lipo -info empty-bin. The other, saner option is to add the following to your plist:

<key>LSArchitecturePriority</key>
<array>
    <string>arm64</string>
</array>

The issue is, MacOS seems to be caching the rosetta flag somewhere outside of the usual places. The only improvement would be if someone finds a way to clear the flag instead of changing the CFBundleIdentifier in the plist.

If the rosetta window appears even once, that bundleId will always summon the window.

2
  • 1
    I've filed a new feedback ticket with Apple. FB14812783. Although they can claim that defaulting to "Intel" is the "intended behavior" (see comments here) there's no excuse to cache this value indefinitely. Description: "If the main application binary is a shell script, it can be launched on macOS without Rosetta by setting the Info.plist LSArchitecturePriority to arm64. However, if this LSArchitecturePriority was not set previously it’s cached as Intel indefinitely." Commented Aug 15, 2024 at 16:07
  • 2
    To clear the cache flag: /usr/libexec/PlistBuddy -c "Delete :\"Architectures for arm64\":com.company.app" ~/Library/Preferences/com.apple.LaunchServices/com.apple.LaunchServices.plist && sudo reboot where com.company.app is the bundle identifier of your application. WARNING: This will reboot your mac if successful. Commented Jun 13, 2025 at 15:40
2

If anyone else is having the same problem, I figured out a way to do this by letting Script Editor do it for me. My script is simply:

do shell script "java -jar drjava.jar"

I exported it this into an application automatically using script editor. It doesn't have an icon but that doesn't really matter.

1

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.