Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
I'm going to start by saying that I'm not a Mac developer and not a Java developer :)

I regularly use an abandoned open-source app called Sears. It's written in Java, but it doesn't run on OS 10.15 because it's 32-bit. I've had a dig around in the .app bundle, and it seems to contain both a .jar file and a compiled 32-bit executable.

Can anyone advise how to rebuild this Java executable for 64-bit? Google isn't being very helpful. I've attached the existing 32-bit app and its source. Hopefully this is trivial when you know how!
 

Attachments

  • Sears_0.83.dmg.zip
    732.1 KB · Views: 150
  • sears-code.zip
    1.9 MB · Views: 150

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
If nobody else jumps in, I'll see if I can do something on Monday. - Since you had the source code it's likely to be possible I can fix it up. Hope you can wait, or if not that someone else jumps in :)
 

konqerror

macrumors 68020
Dec 31, 2013
2,298
3,701
First, try running the jar file directly. If double-clicking doesn't work, install OpenJDK, then in the terminal run java -jar /path/to/file.jar
 

jerwin

Suspended
Jun 13, 2015
2,895
4,651
Right Click on Sears, select "Show package Contents"

Navigate to Contents/Resources/Java/

Right click on Sears-0.83.jar, and select Open (or Open With Jar Launcher).

Examine the resulting application for any usability changes from your previous method of launching the application.
 

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
If nobody else jumps in, I'll see if I can do something on Monday. - Since you had the source code it's likely to be possible I can fix it up. Hope you can wait, or if not that someone else jumps in :)
I'm happy to wait; it's one of those things I've been meaning to post about for months. I'm still on OS 10.13 but am trying to get rid of the last vestiges of 32-bit to make a future upgrade less painful.

First, try running the jar file directly. If double-clicking doesn't work, install OpenJDK, then in the terminal run java -jar /path/to/file.jar
Double-clicking the .jar file does work, but I'd rather fix it 'properly' if possible. If we can't get the executable working then I'll have some follow-up questions around restoring all the functionality (the first thing I noticed is that I can't 'Open With' a .jar file and therefore I'm not sure how to make Sears open when I double-click one of its files).

Examine the resulting application for any usability changes from your previous method of launching the application.
See above.
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
So... This isn't exactly perfect. I haven't tested if everything works; If you find something that's broken let me know.

The thing is that their entire build structure was, well, outdated in a way. OK that's a bit harsh, not the entire thing.
What I'm getting at is that they used private sun.misc classes that aren't guaranteed to be in every JVM and won't compile without special flags to allow it even though it's not meant to be used. They also used a class that just doesn't exist anymore. I made some quick replacements to fix that. The biggest issue was the package jar bundler which is used to make macOS .app packages from jars. Their ant build file was set to use it which is great, I updated it to the latest version from their 1.9 to 3.3 and figured that'd probably allow it to make 64-bit launchers... it did not. - I tried adding a flag that tells it to only run on x86_64 Java runtimes. That still didn't make the launcher 64-bit. So instead I made a shell script for it. To make it feel a bit more "right" I also modified the main method of the program to put the menu bar in the actual macOS menu bar instead of inside the window, and inside the shell script made sure the icon and name of the app is set right, but yeah, it's still not an entirely perfect solution, but try it out and see if it does what it should - I have no idea if it correctly works with auto detecting file extensions to open in Sears, but if not let me know and we'll find a fix.
[automerge]1591036695[/automerge]
I'm happy to wait; it's one of those things I've been meaning to post about for months. I'm still on OS 10.13 but am trying to get rid of the last vestiges of 32-bit to make a future upgrade less painful.
 

Attachments

  • Sears.zip
    642.6 KB · Views: 135

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
I feel a bit guilty now as I didn't expect this to be such an involved process!

Thank you very much. I'm at work at the moment, but I'll give it a go once I get home.

To make it feel a bit more "right" I also modified the main method of the program to put the menu bar in the actual macOS menu bar instead of inside the window

Hmm... the menus have always been in the menu bar on my machine!
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
Hmm... the menus have always been in the menu bar on my machine!

Yes. But not when you just ran the .jar file directly, right?
Putting the menu bar in the, well, menu bar, was handled by the jarbundler program they used to bundle the .app package before. Not by the Sears code itself. Since jarbundler couldn't produce a 64-bit executable, I modified the Sears source code itself to put the menu bar where it should be :). Should work even when opening the jar directly in the app I sent you.

I feel a bit guilty now as I didn't expect this to be such an involved process!

Don't worry about it. I wouldn't have kept digging into it if I weren't having fun with it anyway. Plus I learned things along the way. Had never used ant as a build manager before, so now I got to try that. Had only used cradle before... I prefer cradle haha.
 

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
Yes. But not when you just ran the .jar file directly, right?
Yep, even when I ran the .jar directly (albeit with 'Main' instead of 'Sears' as the first entry).

However, I'm sorry to say that I tried your version and it just briefly flashes up in the dock and then quits. If I try to run your .jar directly then I get a message stating that the jar can't be launched and to check Console for further details, but I can't find anything relevant in there.

I tried copying the unmodified .jar over the top of yours but it still immediately quits. Your script is pretty simple and ls -la shows it to have +x permissions so I'm not sure why it's failing...

Edit: Just tried launching from a Terminal window and got this:

Error: LinkageError occurred while loading main class sears.main.Main
java.lang.UnsupportedClassVersionError: sears/main/Main has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 55.0

I updated my Java to the 'Recommended Version 8 Update 251' from https://www.java.com/en/download/mac_download.jsp and it didn't help.
 
Last edited:

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
Thanks; I got it working :)

I don't know whether I'd ever have got that far without help; you'd think that the front page of java.com would actually say something, rather than having a big 'download' button that leads to an obsolete version...

For anyone else that stumbles upon this thread (or future me!): JDK comes from https://jdk.java.net/14/. You just get a folder containing a bunch of files. This folder needs to be dropped into /Library/Java/JavaVirtualMachines.

Edit: Actually, it looks like I spoke a little too soon. If I double-click an .srt file in Finder then Sears opens, but it doesn't open the file. I suspect that this'll be a simple tweak to the script but I'm not sure what to do. I found if I hardcode a filename to the end of the java command then it opens the file, but I'm not sure how to 'grab' the file that's been clicked on ($1 doesn't do the trick).

Sample .srt follows:

Code:
1
00:00:02,000 --> 00:00:05,000
This is a really simple

2
00:00:05,000 --> 00:00:08,000
sample SRT file.
 
Last edited:

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
While this is a nice programming exercise, try http://www.aegisub.org for a .srt editor solution.
I've tried that in the past and had problems with it, hence the switch to Sears. Naturally I can't remember what the problems were now :)

If we can't get it working then I'll reinvestigate Aegisub, but I'm not currently under any time pressure so I'll see how this conversion goes first.
 
Last edited:
  • Like
Reactions: hwojtek

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
Yep, even when I ran the .jar directly (albeit with 'Main' instead of 'Sears' as the first entry).

Weird; When I tried the .jar directly from the dmg you originally posted it didn't use the menu bar, so I added that manually to the main method of Sears. - Maybe a difference in the Java runtime

I don't know whether I'd ever have got that far without help; you'd think that the front page of java.com would actually say something, rather than having a big 'download' button that leads to an obsolete version...

For anyone else that stumbles upon this thread (or future me!): JDK comes from https://jdk.java.net/14/. You just get a folder containing a bunch of files. This folder needs to be dropped into /Library/Java/JavaVirtualMachines.

I recommend just installing it with home-brew. Much easier and easier to update as well

Edit: Actually, it looks like I spoke a little too soon. If I double-click an .srt file in Finder then Sears opens, but it doesn't open the file. I suspect that this'll be a simple tweak to the script but I'm not sure what to do. I found if I hardcode a filename to the end of the java command then it opens the file, but I'm not sure how to 'grab' the file that's been clicked on ($1 doesn't do the trick).

Hm. I'll look into it. I'm not sure if this can actually be done from a bash script or if maybe a Swift/Objective-C launcher is needed - depends how the information about the double clicked file is given to the launched application, and I don't yet know if there's a way of picking that up from a Bash script. I'll see about it and if not I might make a quick little Swift launcher that does what the bash script did but also passing along a file path when relevant
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
I've tried that in the past and had problems with it, hence the switch to Sears. Naturally I can't remember what the problems were now :)

If we can't get it working then I'll reinvestigate Aegisub, but I'm not currently under any time pressure so I'll see how this conversion goes first.

Hey again;

So I've been working on getting it to play nice with opening files directly from the Finder and have made some progress. - I went back to the drawing board and started looking at new ways of packaging the .app bundle entirely, now using a fork of the app bundler instead of jarbundler for the ant build environment.

In any case, It properly registers with macOS for all the document types, getting the correct icon and opening the program when they're launched, but for me it still didn't actually open the files. And after digging for a long time in the source code I've noticed some more slightly confusing things.

Remember how I said earlier that for me It didn't automatically put the menu bar up in the Mac's menu bar when I ran the jar directly, only after I had made some tweaks? But you said it did for you? Well, now that I've spent more time looking at the source code, it really ought to have done that for me too. I used a different mechanism to achieve it last which worked for me, but there is code in here that should accomplish the same thing.
After digging further, I found that when the program runs, at least on my machine, it actually fails to create the SearsApp object that it uses to integrated with macOS features like getting the file passed from the Finder. It throws an exception upon trying to get a class from Apple's extended awt class library.

Since you didn't have the menu bar issue when running the jar directly I figured you might have a go at testing something for me to see if it's just me having some weird issues with this.

I've added some code to the project that will upon an extra window when the app is launched with the window title "CRASH" and a stack trace in it. If you do not get this window it's a sign that something is working for you that isn't for me.
PS. It will show up as an absolutely tiny window by default cause I couldn't be bothered setting a size for it. It'll be really hard to notice it, and be in the top left. Use Exposé to quickly see if it's there (ctrl+down_arrow or if enabled swipe down with three fingers on the trackpad)

Cheers. Hope it's working for you, but I'll continue digging into it if it's not. Oh and if it is, I'll remove my debugging code and send you a cleaner one. There's a couple of lines here and there that I've just added to give me a visual idea of where things happen and where they don't.


Debugging something without being able to use System.out.print because what you're testing won't show if you run it from a Terminal and having to make Dialog boxes just to get a clue what's happening sucks, haha. Guess I should write a little helper function to write my debug info to a file if I am to work more on this...
Kinda fun though.
The code does have some things that annoy me though. Like, there are places where they make a class when what they really want is an interface, so it's just this empty class that they inherit from for polymorphism. But other places they do use Interfaces, so it's not like they don't know about the language feature. There may be a reason for it but I haven't found it yet. Can't see why you'd want to be able to instantiate a version of it without any method implemented though. Seems like it's just used as an interface.

Anyhow, let me know how the .app in there behaves. Do you get the window with the stack trace (expand the tiny window to see the stack trace inside)?
Does it open files you try and open from the Finder correctly?
Do you have app name, menu bar and icon working properly with it?
 

Attachments

  • Sears.zip
    580 KB · Views: 131

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
Unfortunately I'm back to this again, despite having 14 installed :(

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: sears/main/Main has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0

At this point I think I'm just going to say 'don't worry about it'. You've clearly spent a lot of time on this and I don't want it to spiral even further out of control. Thanks for the attempts though!
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
At this point I think I'm just going to say 'don't worry about it'. You've clearly spent a lot of time on this and I don't want it to spiral even further out of control. Thanks for the attempts though!

Right... I will do so... If this gives the same error :p - I'm not good at just letting something like this be unsolved, hehe. - I've bundled a java runtime with this one. If it gives the same error I'll just let it be, but yeah :p. - But if you don't want to mess around more with it that's also perfectly fine, you don't have to try it if you've had enough. If not, here's another one to give a go and see if it gives the CRASH window with a stack trace or not

Sears.zip
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
Unfortunately I'm back to this again, despite having 14 installed :(



At this point I think I'm just going to say 'don't worry about it'. You've clearly spent a lot of time on this and I don't want it to spiral even further out of control. Thanks for the attempts though!

Scratch that I just got it working on my own machine!!!

Now, holy **** there's a lot to unpack here.
So it turns out that the system the Java code was using to try and integrate with macOS had been deprecated, and was removed past version 8 of Java. That's why it initially had it in the menu bar for you, but not for me when we ran the .jar directly; I was on a newer Java, so for you, the .jar had its code to integrate with Mac running and for me it never fired and it was just generic Java.

Took a lot of research to find that out. Well, seems complete then, rebundle the .app with a copy of the Java 8 runtime packaged with it... Except the tool I used to package the app bundles uses a Java tool that was introduced in Java 9 to bundle the JRE with the app. Had to research how to manually bundle them together, but we finally have it. A fully self contained app bundle with a Java 8 runtime ready to go. This will even run on Macs that've never downloaded and installed Java, since it's all packed together, and it will open files you double click in the Finder and all sorts - at least it does for me. Probably shouldn't promise too much before it's tested on more than just my machine ;)

Oh and also, in Dark Mode it now has a dark window panel. Don't know if it did for you before as well.

But the sad news is that I was using the same system that they did for macOS integration in the, now quite old, Java programs I've written, so that won't work with new Java :(. Gotta rewrite that to use the new Handler class rather than the Adapter class it replaces.

Anyway hope it works for you like it did for me, enjoy:


Link to my web server from before should still work, but just in case

Sears.zip


Bundle is bigger than the original DMG since that one comes bundled with the Java runtime so it's not needed separately and we're sure it's a working version of it
 

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
Not that I expect you to fix it, but just FYI, it broke under 15.1. It's one of two apps on my system with this issue. I use Sears very rarely these days and can still run it by launching the binary directly, so no big deal, just thought you might be interested.
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
Not that I expect you to fix it, but just FYI, it broke under 15.1. It's one of two apps on my system with this issue. I use Sears very rarely these days and can still run it by launching the binary directly, so no big deal, just thought you might be interested.
Hi! Thanks!
In what way did it break? And what do you mean it works when you launch it directly? It's not code signed, which means that in Sequoia you need to try and open it, then go into Settings, Privacy, scroll down and "open anyway", then "open anyway" again. Right click and then "Open" is no longer enough to force macOS to open non code-signed apps.

That said, I do now have a paid Developer Account so I could codesign it but it's also not really my creation, just patched it up, so it does feel weird to codesign and notarise it with Apple
 

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
20,973
4,542
New Zealand
In what way did it break?
Same error as in the linked thread.

And what do you mean it works when you launch it directly?
Show Package Contents, double-click the actual binary instead of the .app bundle.

"Open Anyway" doesn't show up: it behaves exactly like OpenSCAD did until they released a new, signed version. It appears that signing is mandatory in 15.1 (although notarisation isn't). More discussion here and here.
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
Sorry. Hastily read and responded to your first message on my phone so never saw the link.
I can have a look. In the interim; to be able to close the associates terminal window of a program opened that way, ctrl+z it, then bg %1 it to background run the process and disown %1 to make the terminal disown it and hand it over to launchd
Same error as in the linked thread.


Show Package Contents, double-click the actual binary instead of the .app bundle.

"Open Anyway" doesn't show up: it behaves exactly like OpenSCAD did until they released a new, signed version. It appears that signing is mandatory in 15.1 (although notarisation isn't). More discussion here and here.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.